The thresholding is easier, or at least not a greater concern now. What I'm stuck with right now is using the UpdateMotionHistory and CalMotionGradient functions.
From what I understand, videos are just a sequence of images. I don't want to process videos first (neeed to learn how to first) so for the time being I tested the functions on five images, already thresholded and depicting motion.
The problem is that, when using UpdateMotionHistory the five images appear as intended, but the faded out images in each window are not there. It's like the thresholding has no gradual value, differentiating between only black and white.
Can anyone please look up my program and see what's wrong?
I'm using Microsoft visual C++ 2005 BTW.
Code: Select all
#include "cxcore.h"
#include "conio.h"
#include "iostream"
#include "stdafx.h"
#include "ipl.h"
#include "cv.h"
#include "highgui.h"
#include <fstream>
#include "ipl.h"
#include "cv.h"
#include "highgui.h"
IplImage* image1;
IplImage* image2;
IplImage* image3;
IplImage* image4;
IplImage* image5;
IplImage* image6;
IplImage* image7;
IplImage* thresh;
IplImage* mhimage;
IplImage* mask;
IplImage* orient;
//double time = 1000;
double duration = 5;
//double MAX_TIME_DELTA;
//double MIN_TIME_DELTA;
int silhouette();
int mhi1();
int mhi2();
int mhi3();
int mhi4();
int mhi5();
int main ()
{
image1 = cvLoadImage("image5.jpg",0);
image2 = cvLoadImage("image6.jpg",0);
image3 = cvLoadImage("image7.jpg",0);
image4 = cvLoadImage("image8.jpg",0);
image5 = cvLoadImage("image9.jpg",0);
image6 = cvLoadImage("image1.jpg",0);
image7 = cvLoadImage("image2.jpg",0);
thresh = cvCreateImage(cvSize(image7->width, image7->height), IPL_DEPTH_8U, 1);
mhimage = cvCreateImage(cvSize(image1->width, image1->height), IPL_DEPTH_32F, 0);
mask = cvCreateImage( cvSize(image1->width, image1->height), IPL_DEPTH_8U, 1 );
orient = cvCreateImage( cvSize(image1->width, image1->height), IPL_DEPTH_32F, 1);
cvNamedWindow( "Silhouette", 1);
cvShowImage( "Silhouette", thresh);
cvSaveImage( "Silhouette.jpg", thresh);
mhi1();
mhi2();
mhi3();
mhi4();
mhi5();
cvWaitKey (0);
return (0);
}
int mhi1()
{
cvUpdateMotionHistory (image01, mhimage, 10, duration);
cvNamedWindow( "MHI1", 1);
cvShowImage( "MHI1", mhimage);
//cvSaveImage( "MHI1.jpg", mhimage);
return 1;
}
int mhi2()
{
cvUpdateMotionHistory (image02, mhimage, 20, duration);
cvNamedWindow( "MHI2", 1);
cvShowImage( "MHI2", mhimage);
//cvSaveImage( "MHI2.jpg", mhimage);
return 1;
}
int mhi3()
{
cvUpdateMotionHistory (image03, mhimage, 30, duration);
cvNamedWindow( "MHI3", 1);
cvShowImage( "MHI3", mhimage);
//cvSaveImage( "MHI3.jpg", mhimage);
return 1;
}
int mhi4()
{
cvUpdateMotionHistory (image04, mhimage, 40, duration);
cvNamedWindow( "MHI4", 1);
cvShowImage( "MHI4", mhimage);
//cvSaveImage( "MHI4.jpg", mhimage);
return 1;
}
int mhi5()
{
cvUpdateMotionHistory (image05, mhimage, 50, duration);
cvNamedWindow( "MHI5", 1);
cvShowImage( "MHI5", mhimage);
//cvSaveImage( "MHI5.jpg", mhimage);
return 1;
}