hello , I have recently started working on OpenCV using c++.I am having a problem with the following code.
#include "cv.h"
#include "highgui.h"
int g_slider_position = 0;
CvCapture* g_capture = NULL;
void onTrackbarSlide(int pos) {
cvSetCaptureProperty(
g_capture,
CV_CAP_PROP_POS_FRAMES,
pos
);
}
int main( int argc, char** argv ) {
cvNamedWindow( "Example3", CV_WINDOW_AUTOSIZE );
g_capture = cvCreateFileCapture( "Aawaarapan.avi" );
int frames = (int) cvGetCaptureProperty(
g_capture,
CV_CAP_PROP_FRAME_COUNT
);
if( frames!= 0 ) {
cvCreateTrackbar(
"Position",
"Example3",
&g_slider_position,
frames,
onTrackbarSlide //need to be call as onTrackbarSlide(g_slider_position) but gives error:invalid use of void expression
);
}
IplImage* frame;
while(1) {
frame = cvQueryFrame( g_capture );
if( !frame ) break;
cvShowImage( "Example3", frame );
cvCreateTrackbar(
"Position",
"Example3",
&g_slider_position,
frames,
onTrackbarSlide
);
char c = cvWaitKey(33);
if( c == 27 ) break;
++g_slider_position;
}
cvReleaseCapture( &g_capture );
cvDestroyWindow( "Example3" );
return(0);
}
here the call to the function cvCreateTrackbar
takes as argument, the function
void onTrackbarSlide(int pos)
but when i call the function like this cvCreateTrackbar( "Position", "Example3", &g_slider_position, frames, onTrackbarSlide(g_slider_position) );`
it is reporting an error
error: invalid use of void expression
Actually i need to pass the g_slider_position to the function so that the slider's position is known.
A friend of mine told me to call the function as
cvCreateTrackbar(
"Position",
"Example3",
&g_slider_position,
frames,
onTrackbarSlide
);
this doesn't report any error but it doesn't do what it is supposed to.the slider's position is necessary.
So, my question is how do i call the cvCreateTracker with argument onTrackerSlide(with its integer argument).hope i was not confusing . Thank you !!!!