auto image process system

i have found a source code which can process an image and take its grayscale.
but I have to change the file name everytime.

I want to improve it to a system which can capture photo and process the image automatically.

what should I add on the source code?




#include <cstdlib>
#include <iostream>

#include <cv.h>
#include <highgui.h>
#include <stdio.h>

int main()
{
IplImage *Image1=cvLoadImage("IMG_1282.jpg",1);

double MinValue;
double MaxValue;

CvPoint MinLocation;
CvPoint MaxLocation;

cvSetImageCOI(Image1,1);
cvMinMaxLoc(Image1,&MinValue,&MaxValue,&MinLocation,&MaxLocation);

printf("The Min number is : %.f\n",MinValue);
printf("The position is : ( %d , %d )\n",MinLocation.x,MinLocation.y);
printf("The Max number is : %.f\n",MaxValue);
printf("The position is : (%d , %d )\n",MaxLocation.x,MaxLocation.y);

cvNamedWindow("grotto",1);
cvShowImage("grotto",Image1);
cvWaitKey(0);
}
Topic archived. No new replies allowed.