查看完整版本: visual C++ 的錯誤問題 Runtime library
頁: [1]

j841205y 發表於 2016-12-12 12:00 AM

visual C++ 的錯誤問題 Runtime library

由於大學專題研究的關西,小弟最近開始在碰visual studio
我上網copy了一段程式後執行,一直會跑出這錯誤訊息
請問有人知道為什麼 如何解決嗎??


此為copy的程式碼:
#include <stdio.h>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <ctype.h>

using namespace cv;
using namespace std;

void contourFilter(Mat image, Mat skin_img)
{
        RNG rng(12345);
        Mat threshold_img;
        vector<vector<Point> > contours;
        vector<Vec4i> hierarchy;

        threshold(skin_img, threshold_img, 125, 255, THRESH_BINARY);
        //將skin_img二值化

        findContours(threshold_img, contours, hierarchy,
                CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
        //在threshold_img影像中尋找所有的輪廓

        vector<vector<Point> > contours_poly(contours.size());
        vector<Rect> boundRect(contours.size());

        for (int i = 0; i < contours.size(); i++)
        {
                approxPolyDP(Mat(contours), contours_poly, 3, true);
                //計算可以包含輪廓的最小長方形區域

                boundRect = boundingRect(Mat(contours_poly));

                Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
                //隨機給一個顏色

                if (boundRect.area() > 900)
                {//長方形區域面積超過900,則畫在影像上
                        drawContours(image, contours_poly, i, color, 1, 8, vector<Vec4i>(), 0, Point());
                        rectangle(image, boundRect.tl(), boundRect.br(), color, 2, 8, 0);
                }
        }
        namedWindow("Contours", CV_WINDOW_AUTOSIZE);
        imshow("Contours", image);
}
int main(int argc, char** argv)
{
        VideoCapture cap;
        cap.open(0);;
        namedWindow("OpenCV Demo", 0);

        Mat image;
        Mat hsvImg, skinImg, resizeImg;

        for (;;)
        {
                Mat frame;
                cap >> frame;
                if (frame.empty())
                        break;

                cv::resize(frame, resizeImg, cv::Size(320, 240));
                resizeImg.copyTo(image);

                cvtColor(image, hsvImg, CV_BGR2HSV);
                inRange(hsvImg, Scalar(0, 58, 20), Scalar(50, 173, 230), skinImg);
                //篩選hsvImg在HSV顏色空間屬於膚色的區域

                cv::dilate(skinImg, skinImg, Mat(), Point(-1, -1), 3);
                //對skinImg進行膨脹

                cv::erode(skinImg, skinImg, Mat(), Point(-1, -1), 3);
                //對skinImg進行侵蝕

                contourFilter(image, skinImg);
                imshow("OpenCV Demo", skinImg);
                waitKey(10);
        }

        return 0;
}

...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div><div></div>

nypor 發表於 2016-12-15 12:15 AM

Input to certain openCV API is wrong.
Suggest u study every line code, make sure u understand, and check every line runs without error.
頁: [1]