Ask Your Question

Mohammed Magdy's profile - activity

2018-01-19 23:15:01 -0500 received badge  Famous Question (source)
2015-01-14 06:45:13 -0500 received badge  Notable Question (source)
2014-06-24 05:19:38 -0500 received badge  Popular Question (source)
2013-02-18 11:43:19 -0500 asked a question Return RGB values of the the current Pixel ?

How to return the RGB values of the current Pixel i stop on it by the mouse cursor??

My Code:

#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <iostream>

void mouseEvent(int evt, int x, int y, int flags, void* param){
    evt==CV_EVENT_MOUSEMOVE;
    printf("Current Position: x= %d y= %d\n",x,y);
}

int main() 
{
cvNamedWindow("rgb"); 
CvCapture*capture =cvCaptureFromCAM(0);
IplImage* rgb ;

while(1){
rgb= cvQueryFrame( capture ); 
cvShowImage("rgb",rgb);
cvSetMouseCallback("rgb",  mouseEvent, 0);



char c = cvWaitKey(33);
if( c == 27 ) break;
}

cvReleaseCapture( &capture );
cvDestroyWindow( "rgb" );

}