2013-12-16 1 views
0

Windows 서버 2012 및 VS2012 (업데이트 3)에서 OpenCV 2.4.7을 사용하고 opencv-2.4.7.2.exe에서 추출한 다음 opencv 자습서를 통해 Windows 및 Visual Studio에 필요한 경로를 추가했습니다. 빌드 후 코드가 작동하지 않습니다 (-5 반환),하지만 내가 중단 점을 설정할 때 frame = cvQueryFrame(capture); 프로그램이 작동합니다. 이 줄 뒤 및 앞에 cvWaitKey(33);을 사용하면 아무 것도 수행하지 않습니다.open cv가 중단 점을 설정할 때까지 비디오를 캡처하지 않습니다.

a4tech 웹캠을 사용하여 문제가없는 일부 웹캠 소프트웨어로 웹캠을 테스트했습니다. 또한 나는 어떤 제 3 자 DLL도 tbb와 같지 않습니다.

'test1.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'L:\Projects\opencv\opencv\build\x64\vc11\bin\opencv_core247d.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'L:\Projects\opencv\opencv\build\x64\vc11\bin\opencv_imgproc247d.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'L:\Projects\opencv\opencv\build\x64\vc11\bin\opencv_highgui247d.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\msvcp110d.dll'. Symbols loaded. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\msvcr110d.dll'. Symbols loaded. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\oleaut32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.9200.16658_none_776622cb3175a40c\comctl32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\msvfw32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\avifil32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\avicap32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\winmm.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\msacm32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\winmmbase.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\msctf.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\cryptbase.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\uxtheme.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\clbcatq.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\devenum.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\setupapi.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\cfgmgr32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\devobj.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\ntmarta.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\wintrust.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\crypt32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\msasn1.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\msdmo.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\qcap.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\quartz.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\dwmapi.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\ksproxy.ax'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\ksuser.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\d3d9.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\vidcap.ax'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\Kswdmcap.ax'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\mfc42.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\odbc32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\qedit.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\comdlg32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\WinSxS \amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.9200.16518_none_726fbfe0cc22f012\GdiPlus.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\SHCore.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\ddraw.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\dciman32.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\igdumd64.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Unloaded 'C:\Windows\System32\igdumd64.dll' 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\igdumd64.dll'. Cannot find or open the PDB file. 
'test1.exe' (Win32): Unloaded 'C:\Windows\System32\igdumd64.dll' 
'test1.exe' (Win32): Loaded 'C:\Windows\System32\msyuv.dll'. Cannot find or open the PDB file. 

The thread 0x1efc has exited with code -5 (0xfffffffb). 
The thread 0x1540 has exited with code -5 (0xfffffffb). 
The thread 0x1160 has exited with code -5 (0xfffffffb). 
The thread 0x1af8 has exited with code -5 (0xfffffffb). 
The thread 0x1c84 has exited with code -5 (0xfffffffb). 

이 코드의 문제점은 무엇인가 : Visual Studio를 출력 창에

, 나는이 라인을 얻을? 또는 내 구성?

#include "stdafx.h" 

#include <cv.h> 
#include <highgui.h> 

IplImage* imgTracking; 
int lastX = -1; 
int lastY = -1; 

//This function threshold the HSV image and create a binary image 
IplImage* GetThresholdedImage(IplImage* imgHSV){  
    IplImage* imgThresh=cvCreateImage(cvGetSize(imgHSV),IPL_DEPTH_8U, 1); 
cvInRangeS(imgHSV, cvScalar(160,160,60), cvScalar(180,256,256), imgThresh); 
return imgThresh; 
} 

void trackObject(IplImage* imgThresh){ 
// Calculate the moments of 'imgThresh' 
CvMoments *moments = (CvMoments*)malloc(sizeof(CvMoments)); 
cvMoments(imgThresh, moments, 1); 
double moment10 = cvGetSpatialMoment(moments, 1, 0); 
double moment01 = cvGetSpatialMoment(moments, 0, 1); 
double area = cvGetCentralMoment(moments, 0, 0); 

if(area>1000){ 
    // calculate the position of the ball 
    int posX = moment10/area; 
    int posY = moment01/area;   

    if(lastX>=0 && lastY>=0 && posX>=0 && posY>=0) { 
     // Draw a line from the previous point to the current point 
     cvLine(imgTracking, cvPoint(posX, posY), cvPoint(lastX, lastY), cvScalar(0,0,255), 4); 
    } 
    lastX = posX; 
    lastY = posY; 
} 

free(moments); 
} 


int main(){ 

CvCapture* capture =0;  
//....1....cvWaitKey(500); this does nothing 
capture = cvCaptureFromCAM(0); 
//Following line also tested, and nothing happened 
//cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640); 
//cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480); 
if(!capture){ 
     printf("Capture failure\n"); 
     return -10; 
} 

IplImage* frame=0; 
//....2....cvWaitKey(33); 33 ms delay, does nothing at all 
frame = cvQueryFrame(capture); 
//....3....cvWaitKey(33); 33 ms delay, does nothing at all 
if(!frame) return -5; 

//create a blank image and assigned to 'imgTracking' which has the same size of original video 
imgTracking=cvCreateImage(cvGetSize(frame),IPL_DEPTH_8U, 3); 
//covert the image, 'imgTracking' to black 
cvZero(imgTracking); 

cvNamedWindow("Video");  
cvNamedWindow("Ball"); 

//iterate through each frames of the video  
while(true){ 

    frame = cvQueryFrame(capture);   
    if(!frame) break; 
    frame=cvCloneImage(frame); 

    //smooth the original image using Gaussian kernel 
    cvSmooth(frame, frame, CV_GAUSSIAN,3,3); 

    IplImage* imgHSV = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3); 
    //Change the color format from BGR to HSV 
    cvCvtColor(frame, imgHSV, CV_BGR2HSV); 
    IplImage* imgThresh = GetThresholdedImage(imgHSV); 

    //smooth the binary image using Gaussian kernel 
    cvSmooth(imgThresh, imgThresh, CV_GAUSSIAN,3,3); 

    //track the possition of the ball 
    trackObject(imgThresh); 

    // Add the tracking image and the frame 
    cvAdd(frame, imgTracking, frame); 

    cvShowImage("Ball", imgThresh);   
    cvShowImage("Video", frame); 

    //Clean up used images 
    cvReleaseImage(&imgHSV); 
    cvReleaseImage(&imgThresh);    
    cvReleaseImage(&frame); 

    //Wait 10mS 
    int c = cvWaitKey(33); 
    //If 'ESC' is pressed, break the loop 
    if((char)c==27) break;  
} 

cvDestroyAllWindows() ; 
cvReleaseImage(&imgTracking); 
cvReleaseCapture(&capture);  

return 0; 
} 

답변

1
//....2....cvWaitKey(33); 33 ms delay, does nothing at all 

열린 창문이있는 경우는 33 밀리 초를 대기 때문에 이것은 예상 된 동작입니다. 이 줄을 사용하려면 그 줄 앞에 창을 열어야합니다.

그리고 frame = cvQueryFrame(capture); 라인을 두 번 실행 해보십시오. 어떤 이유로 이미지가 처음에는 캡처되지 않을 수도 있습니다. 시도해보십시오.

+0

아무 것도 수행되지 않았 음을 확인하고 다시 중단 점을 설정하면 코드가 작동합니다. –

+0

내 감정을 표현할 수는 없지만, 첫 번째 코멘트 후에 편집을보고 두 번'frame = cvQueryFrame (capture);'가 작동합니다. –

+1

그리고 하나의 조언은 오래된 C-API 사용을 중단하고 C++ API 사용을 시작하십시오. – guneykayim

관련 문제