I encounter the R6010 error...
As i am new to opencv, i tried some tutorial on the youtube channel.
https://www.youtube.com/watch?v=2i2bt-YSlYQ
However, when i started the program without debugging, it told me that there are some problems related to r6010.
the command window also show that "OpenCV Error: Assertion failed(src1.size == dst.size&&dst.type()==CV_8U) in unknown function, file ........\ocv\opencv\modules\core\src\arithm.ccp, line 1882"
my code is the following:
#include <opencv/cvaux.h>
#include <opencv/highgui.h>
#include <opencv/cxcore.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char*argv[]){
CvSize size640x480 = cvSize(640,480);
CvCapture* p_capWebcam;
IplImage* p_imgOriginal;
IplImage* p_imgProcessed;
CvMemStorage* p_strStorage;
CvSeq* p_seqCircles;
float* p_fltXYRadius;
int i;
char charCheckForEscKey;
p_capWebcam = cvCaptureFromCAM(0);
if(p_capWebcam == NULL){
printf("error: capture is NULL\n");
getchar();
return(-1);
}
cvNamedWindow("Original");
cvNamedWindow("Processed");
p_imgProcessed = cvCreateImage(size640x480, IPL_DEPTH_8U, 1);
while(1){
p_imgOriginal = cvQueryFrame(p_capWebcam);
if(p_imgOriginal == NULL){
printf("error: frame is NULL\n");
getchar();
break;
}
cvInRangeS(p_imgOriginal, CV_RGB(175, 0, 0), CV_RGB(256, 100, 100), p_imgProcessed);
p_strStorage = cvCreateMemStorage(0);
cvSmooth(p_imgProcessed, p_imgProcessed);
p_seqCircles = cvHoughCircles(p_imgProcessed, p_strStorage, CV_HOUGH_GRADIENT, 2, p_imgProcessed->height / 4,100,50,10,400);
for(i=0; i<p_seqCircles->total; i++){
p_fltXYRadius = (float*)cvGetSeqElem(p_seqCircles, i);
printf("ball position x= %f, y=%f, r=%f \n", p_fltXYRadius[0],
p_fltXYRadius[1],
p_fltXYRadius[2]);
cvCircle(p_imgOriginal, cvPoint(cvRound(p_fltXYRadius[0]),cvRound(p_fltXYRadius[1])),3,CV_RGB(0, 255, 0),CV_FILLED);
cvCircle(p_imgOriginal,cvPoint(cvRound(p_fltXYRadius[0]),cvRound(p_fltXYRadius[1])), cvRound(p_fltXYRadius[2]), CV_RGB(255,0,0),3);
}
cvShowImage("Original", p_imgOriginal);
cvShowImage("Processed", p_imgProcessed);
cvReleaseMemStorage(&p_strStorage);
charCheckForEscKey = cvWaitKey(10);
if(charCheckForEscKey == 27) break;
}
cvReleaseCapture(&p_capWebcam);
cvDestroyWindow("Original");
cvDestroyWindow("Processed");
return (0);
}
rule 1: anything with IplImages in it is dead
To expand a bit on @berak his comment. OpenCV had a major workover when shifting to version 2. They switched from the old and depricated C-API to a newer and more user friendly C++-API which is being used and developed extensively now. However many tutorials are still out there from the old days, mixing it up for new users. Basically rule 1 says that if you do not see the
Mat
element used, instead of the oldIplImage
, you need to go look for better tutorials. Good luck!Btw if you are looking for better tutorials, start here.