#include #include #include #include #include int main(int argc, char *argv[]) { int redpixelcount = 0; if(argc < 4){ printf("Usage error: a.out \n"); exit(1); } CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY); if(!capture){ fprintf(stderr, "Error: capture is NULL \n"); getchar(); return -1; } IplImage* img = cvQueryFrame(capture); //load image from webcam capture IplImage* copy = cvCreateImage(cvGetSize(img),8,3); //create a new image of 8 bit 3 channel CvScalar s, c; printf("Searching for Red pixels...\n"); for(int i=0;i<(img->height);i++){ //in the 2d array of the image.. count till the vertical pixel reaches the height of img for(int j=0;j<(img->width);j++){ //in the 2d array of the image.. count till horizontal pixel reaches the width of img s=cvGet2D(img,i,j); //get the RGB values of img's i,j, into a scalar container, s if((s.val[2]>atoi(&*argv[1]))&&(s.val[1]redlower && GREEN