2014-07-08 2 views
0

나는이 질문이 많은 횟수를 물어 봤고 답변을 구현하려고하지만 내 코드에서 예외가 발생하고 있음을 알고 있습니다.opencv C++ HSV 이미지 채널 분리 예외

OS : 윈도우 7 OpenCV의 : TrackColour에 0x62B978C9 (opencv_core249.dll)에서 "처리되지 않은 예외 :

#include "stdafx.h" 

#include <iostream> 
#include <stdio.h> 
#include <stdlib.h> 
#include "opencv2/highgui/highgui.hpp" 
#include "opencv2/imgproc/imgproc.hpp" 

using namespace cv; 
using namespace std; 

int main(int argc, char** argv) 
{ 
    VideoCapture cap(0); //capture the video from webcam 

    if (!cap.isOpened()) // if not success, exit program 
    { 
     cout << "Cannot open the web cam" << endl; 
     return -1; 
    } 

    Mat imgHSV; 
    _sleep(100); //give the camera a chance to wake up 
    while (true) 
    { 
     Mat imgOriginal; 
     bool success = cap.read(imgOriginal); 
     if (!success) //if not success, break loop 
     { 
      cout << "Cannot read a frame from video stream" << endl; 
      break; 
     } 



    cvtColor(imgOriginal, imgHSV, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV 
     vector<Mat> hsv_planes; 
    split(imgHSV, hsv_planes); 
//hsv_planes[0] // H channel 
//hsv_planes[1] // S channel 
//hsv_planes[2] // V channel 
    imshow(thresholded_window, hsg_planes[2]); //show the S channel 
     if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop 
     { 
      cout << "esc key is pressed by user" << endl; 
      break; 
     } 
    } 

    return 0; 
} 

예외가 분할 선에 발생합니다 : 2.4.9 여기

내 코드입니다 .exe : 0xC0000005 : 0xFEEEFEEE 위치를 쓰는 액세스 위반. "

답변

1

나는 내 문제를 알아 냈고, 다른 누군가에게 일어난다.

VS에서 나는 디버그 빌드를하고 있었지만 opencv의 비 디버그 버전에 연결하고있었습니다. opencv_core249라는 에러 메시지에서 opencv_core249d ('d'에주의)가 있어야합니다. 디버그 라이브러리를 사용하기 위해 CV 연결을 업데이트했습니다.

다른 opencv 호출이 잘못된 라이브러리를 사용하여 정상적으로 수행되었지만, 무엇인가는 split과 고유해야합니다.