Hi all!

i'm working on an webcam video streaming application.. The application has several parts.

Qt Code:
  1. //Part 1, Frame Grabber
  2. int main(int argc, char **argv)
  3. {
  4. CvCapture *capture;
  5. IplImage *frame;
  6. IplImage *frame1;
  7. IplImage *frame2;
  8.  
  9. double t,ms = 0;
  10. int key = 0;
  11.  
  12. /* Initialize webcam and window */
  13. capture = cvCaptureFromCAM(0);
  14. cvNamedWindow("JCXSUPERTAMARK5",1);
  15.  
  16. while (key != 'q')
  17. {
  18. t = (double)cvGetTickCount();
  19.  
  20.  
  21. /* show the image from webcam */
  22. frame = cvQueryFrame(capture);
  23. cvShowImage("JCXSUPERTAMARK5",frame);
  24. key = cvWaitKey(1);
  25.  
  26. /* converting.. . */
  27.  
  28. frame1 = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
  29. cvCvtColor(frame, frame1, CV_BGR2GRAY);
  30. frame2 = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 1);
  31.  
  32. cvResize(frame1,frame2);
  33.  
  34. /* GET ELAPSED TIME */
  35. t = (double)cvGetTickCount() -t;
  36. ms += t / ((double)cvGetTickFrequency() * 1000.0);
  37.  
  38. /* 0.04 sec auto save (25 frame per sec.) */
  39. if (ceil(ms) >= 40)
  40. {
  41. cvSaveImage("test.png",frame2);
  42. ms = 0;
  43. }
  44. }
  45.  
  46. /* free up memory */
  47. cvReleaseCapture(&capture);
  48. cvDestroyWindow("JCXSUPERTAMARK5");
  49.  
  50. return 0;
  51. }
  52.  
  53. //Part 2, image sender
  54. QImage image;
  55. image.load("../appSendImage/test.png", "PNG"); // Prepare / load an image
  56. QString address = "127.0.0.1";
  57. int port = 6667;
  58. SendImage s(address, port); // Construct SendImage and give the server address and port
  59. s.send(image, "test.png");
To copy to clipboard, switch view to plain text mode 

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_Surv...and_Javascript
Part 2 :
http://www.hanckmann.net/?q=node/44