Problem with cvCompareHist
Hi I'm trying to use cvCompareHist to detect an object entering the frame all the methods seem to be returning a value except for cvCompareHist the code builds succesfully with no errors and crashes at runtime when I quick watch the cvCompreHist method I get an error "CX0017: Error:symbol "cvCompareHist" not found". Here's the code till that point
#include "opencv\cv.h"
#include"opencv2\core\core.hpp" // Basic OpenCV structures (cv::Mat, Scalar)
#include "opencv\highgui.h" // OpenCV window I/O
#include "opencv2\imgproc\imgproc.hpp"
#include <iostream> // for standard I/O
#include <string> // for strings
#include <iomanip> // for controlling float print precision
#include <sstream> // string to number conversion
#include <stdio.h>
void ImagesAreDifferent(IplImage* frame, IplImage* previousFrame);
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
cvNamedWindow( "Example2", CV_WINDOW_AUTOSIZE ); //creates window
//CvCapture* capture = cvCreateCameraCapture( -1); //to select camera
CvCapture* capture = cvCreateFileCapture("test video.mp4"); //uses test video
IplImage* frame; //holds one frame from the video/camera
IplImage* referenceFrame = NULL; //will hold the reference frame
IplImage* currentFrame = NULL;
IplImage* h_plane = NULL;
IplImage* s_plane = NULL;
IplImage* v_plane = NULL;
IplImage* h_planeC = NULL;
IplImage* s_planeC = NULL;
IplImage* v_planeC= NULL;
IplImage* previousFrame = NULL; //this is used to determine if the object is moving
/// Using 30 bins for hue and 32 for saturation
int h_bins = 30; int s_bins = 32;
// Build and fill the histogram
CvHistogram* frameA;
{
int hist_size[] = { h_bins, s_bins };
float h_ranges[] = { 0, 255 };
float s_ranges[] = { 0, 180 };
float* ranges[] = { h_ranges, s_ranges };
frameA = cvCreateHist( 2, hist_size, CV_HIST_ARRAY, ranges, 1 );
}
CvHistogram* frameB;
{
int hist_size[] = { h_bins, s_bins };
float h_ranges[] = { 0, 255 };
float s_ranges[] = { 0, 180 };
float* ranges[] = { h_ranges, s_ranges };
frameB = cvCreateHist( 2, hist_size, CV_HIST_ARRAY, ranges, 1 );
}
bool firstFrame = true;
while(1) //run indefinitely
{
frame = cvQueryFrame( capture ); //takes the next frame
//sets the reference frame
if(firstFrame)
{
//these are the three layers from the color scheme we are converting to
//the change in color scheme is for better comparison
h_plane = cvCreateImage( cvGetSize(frame), 8, 1);
s_plane = cvCreateImage( cvGetSize(frame), 8, 1);
v_plane = cvCreateImage( cvGetSize(frame), 8, 1);
referenceFrame = cvCreateImage(cvGetSize(frame), 8,3); //set the reference frame
cvCvtColor(frame, referenceFrame, CV_BGR2HSV); //change the color scheme
IplImage* referenceFrameArray[] = {h_plane, s_plane}; //put the h and s layers into an array for creation of the histogram
cvCvtPixToPlane( referenceFrame, h_plane, s_plane, v_plane, 0); //break the image into the three layers
cvCalcHist(referenceFrameArray, frameA, 0, 0); //calculate the histogram value
cvNormalizeHist( frameA, 1.0); //normalize the histogram
firstFrame = false;
}
else
{
//these are the three layers from the color scheme we are converting to for current frame
h_planeC = cvCreateImage( cvGetSize(frame), 8, 1);
s_planeC = cvCreateImage( cvGetSize(frame), 8, 1);
v_planeC = cvCreateImage( cvGetSize(frame), 8, 1);
//get histograms for fast simple comparison of frames
currentFrame = cvCreateImage(cvGetSize(frame), 8,3); //set the current frame
cvCvtColor(frame, currentFrame, CV_BGR2HSV); //change the color scheme
IplImage* currentFrameArray[] = {h_planeC, s_planeC}; //put the h and s layer into an array for creation of the histogram
cvCvtPixToPlane( currentFrame, h_planeC, s_planeC, v_planeC, 0); //break apart the image into the three layers
cvCalcHist(currentFrameArray, frameB, 0, 0 ...