bajoelkid12
19th June 2011, 18:57
Hi all!
i'm working on an webcam video streaming application.. The application has several parts.
//Part 1, Frame Grabber
int main(int argc, char **argv)
{
CvCapture *capture;
IplImage *frame;
IplImage *frame1;
IplImage *frame2;
double t,ms = 0;
int key = 0;
/* Initialize webcam and window */
capture = cvCaptureFromCAM(0);
cvNamedWindow("JCXSUPERTAMARK5",1);
while (key != 'q')
{
t = (double)cvGetTickCount();
/* show the image from webcam */
frame = cvQueryFrame(capture);
cvShowImage("JCXSUPERTAMARK5",frame);
key = cvWaitKey(1);
/* converting.. . */
frame1 = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
cvCvtColor(frame, frame1, CV_BGR2GRAY);
frame2 = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 1);
cvResize(frame1,frame2);
/* GET ELAPSED TIME */
t = (double)cvGetTickCount() -t;
ms += t / ((double)cvGetTickFrequency() * 1000.0);
/* 0.04 sec auto save (25 frame per sec.) */
if (ceil(ms) >= 40)
{
cvSaveImage("test.png",frame2);
ms = 0;
}
}
/* free up memory */
cvReleaseCapture(&capture);
cvDestroyWindow("JCXSUPERTAMARK5");
return 0;
}
//Part 2, image sender
QImage image;
image.load("../appSendImage/test.png", "PNG"); // Prepare / load an image
QString address = "127.0.0.1";
int port = 6667;
SendImage s(address, port); // Construct SendImage and give the server address and port
s.send(image, "test.png");
And i want these parts to be run in different threads. How can i implement QThread
in my application ? Need your advice please.. .
code reference :
Part 1 :
http://nashruddin.com/Web_Based_Surveillance_System_with_OpenCV_PHP_and_ Javascript
Part 2 :
http://www.hanckmann.net/?q=node/44
i'm working on an webcam video streaming application.. The application has several parts.
//Part 1, Frame Grabber
int main(int argc, char **argv)
{
CvCapture *capture;
IplImage *frame;
IplImage *frame1;
IplImage *frame2;
double t,ms = 0;
int key = 0;
/* Initialize webcam and window */
capture = cvCaptureFromCAM(0);
cvNamedWindow("JCXSUPERTAMARK5",1);
while (key != 'q')
{
t = (double)cvGetTickCount();
/* show the image from webcam */
frame = cvQueryFrame(capture);
cvShowImage("JCXSUPERTAMARK5",frame);
key = cvWaitKey(1);
/* converting.. . */
frame1 = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
cvCvtColor(frame, frame1, CV_BGR2GRAY);
frame2 = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 1);
cvResize(frame1,frame2);
/* GET ELAPSED TIME */
t = (double)cvGetTickCount() -t;
ms += t / ((double)cvGetTickFrequency() * 1000.0);
/* 0.04 sec auto save (25 frame per sec.) */
if (ceil(ms) >= 40)
{
cvSaveImage("test.png",frame2);
ms = 0;
}
}
/* free up memory */
cvReleaseCapture(&capture);
cvDestroyWindow("JCXSUPERTAMARK5");
return 0;
}
//Part 2, image sender
QImage image;
image.load("../appSendImage/test.png", "PNG"); // Prepare / load an image
QString address = "127.0.0.1";
int port = 6667;
SendImage s(address, port); // Construct SendImage and give the server address and port
s.send(image, "test.png");
And i want these parts to be run in different threads. How can i implement QThread
in my application ? Need your advice please.. .
code reference :
Part 1 :
http://nashruddin.com/Web_Based_Surveillance_System_with_OpenCV_PHP_and_ Javascript
Part 2 :
http://www.hanckmann.net/?q=node/44