2012-01-24 34 views
0

我在做的OpenCV的项目... I M得到错误这样应用程序崩溃说:访问冲突读取位置0xbaadf04d

“在0x775a15ee在touch.exe未处理的异常:0000005:访问冲突读取位置0xbaadf04d。”

代码

using namespace std; 

#include "stdafx.h" 
#include "cv.h" 
#include "cxcore.h" 
#include "highgui.h" 
#include "math.h" 
#include <iostream> 
#include <stdio.h> 
#include <string.h> 
#include <conio.h> 
#include <sstream> 

int main(int argc, char* argv[]){ 
    //declerations 

    CvCapture *frame=0; 
    IplImage *image=0; 

    cvNamedWindow("Image taken", CV_WINDOW_AUTOSIZE); 
    frame=cvCreateCameraCapture(2); 
    frame=cvCreateCameraCapture(2); 
    image = cvQueryFrame(frame); 
    cvShowImage("Image taken", image); 
    cvWaitKey(0); 

    return 0; 
} 
+0

cvCreateCameraCapture(2)更换

frame=cvCreateCameraCapture(2); 

- 为什么2? – zrxq

回答

1

尝试用

frame=cvCreateCameraCapture(-1); 
if (!frame) { 
    puts("Couldn't detect a camera."); 
    return(1); 
} 
+0

嘿感谢答复这个问题得到了解决,但我有相机越来越另一个问题,但“拍摄的图像”越来越黑,所以我所做的更改和代码是 \t这是工作的罚款可我知道原因 –

+0

INT主(int argc,char * argv []){ \t // declerations \t \t CvCapture * frame = 0; \t IplImage * image = 0; \t对(INT I = 1; I <1000;我++){ \t帧= cvCreateCameraCapture(1); \t // frame = cvCreateCameraCapture(1); \t \t if(!frame){ \t \t puts(“Could not detect a camera。”); \t \t返回(1); \t} \t \t image = cvQueryFrame(frame); \t cvNamedWindow( “图像拍摄”,CV_WINDOW_AUTOSIZE); \t cvShowImage(“拍摄图片”,图片); \t cvWaitKey(1000); \t} \t cvReleaseImage(图像); \t return 0; } –

+0

不要劫持自己的线程,如果你有无关的电流不同的问题,随便问一个问题在一个新的线程。 – karlphillip