Professional Documents
Culture Documents
Code 1
Code 1
hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <cv.h>
{
VideoCapture cap(0); //capture the video from
webcam
return -1;
for(int i=0;i<50;i++)
Mat imgOriginal;
cout << "Cannot read a frame from video stream" << endl;
break;
Mat imgHSV;
Mat imgThresholded;
if (iLastX >= 0 && iLastY >= 0 && posX >= 0 && posY >= 0)
if (posX >= 0 && posX <=640 && posY >= 0 && posY <= 479)
{
printf("DETECTED...\n");
imwrite("khk.jpg", imgOriginal);
sleep(2);
break;
iLastX = posX;
iLastY = posY;
else
imshow("Original", imgOriginal);
//show the original image
waitKey(33);
return 0;