The following code is sending me into an Access violation reading location 0x025e2000 - I'm a novice programmer and I'm hoping somebody can point me in the right direction
I'm trying to achieve a green screen application, but the code falls over while indexing through the image pixels, at x=482, y=64.
I look forward to your wisdom.
Code:
CvCapture * Capture=NULL; Capture = cvCaptureFromCAM(-1); IplImage* FrameImage = 0; IplImage* MirrorImage = 0; for(;;) { FrameImage = cvQueryFrame(Capture); MirrorImage = cvCloneImage(FrameImage); cvFlip(MirrorImage, NULL, 1); int b, r, g; //colour channels int x, y; //For indexing through image cvNamedWindow( "OutPut", CV_WINDOW_AUTOSIZE ); for ( x = 0; x < MirrorImage->width; x++ ) { for ( y = 0; y < MirrorImage->height; y++ ) { b = ((uchar *)(MirrorImage->imageData + x*MirrorImage->widthStep))[y*MirrorImage->nChannels+0]; g = ((uchar *)(MirrorImage->imageData + x*MirrorImage->widthStep))[y*MirrorImage->nChannels+1]; r = ((uchar *)(MirrorImage->imageData + x*MirrorImage->widthStep))[y*MirrorImage->nChannels+2]; if ( !( g > 170 && r < 150 && b < 150 ) ) { (FrameImage->imageData + x*FrameImage->widthStep)[y*FrameImage->nChannels+0]=(MirrorImage->imageData + x*MirrorImage->widthStep)[y*MirrorImage->nChannels+0]; (FrameImage->imageData + x*FrameImage->widthStep)[y*FrameImage->nChannels+1]=(MirrorImage->imageData + x*MirrorImage->widthStep)[y*MirrorImage->nChannels+1]; (FrameImage->imageData + x*FrameImage->widthStep)[y*FrameImage->nChannels+2]=(MirrorImage->imageData + x*MirrorImage->widthStep)[y*MirrorImage->nChannels+2]; } } } cvShowImage(WinName, FinImage); cvShowImage("OutPut", FrameImage); }
I look forward to your wisdom.
Comment