Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cv.h>
  3. #include "opencv2/highgui/highgui.hpp"
  4. #include <windows.h>
  5. int main(int argc, char *argv[])
  6. {
  7. __int64 Start;
  8. __int64 End;
  9. __int64 Freq;
  10. QueryPerformanceCounter((LARGE_INTEGER *)&Start);
  11. CvCapture* capture = cvCreateCameraCapture(0);
  12. if (!capture)
  13. {
  14. return 0;
  15. }
  16. QueryPerformanceCounter((LARGE_INTEGER *)&End);
  17. QueryPerformanceFrequency((LARGE_INTEGER *)& Freq);
  18. double time = (End ­ Start) * 1000 / Freq;
  19. std::cout << "initialization time: " << time << " ms" << std::endl;
  20. int fps = 0;
  21. QueryPerformanceCounter((LARGE_INTEGER *)&Start);
  22. while (1)
  23. {
  24. ++fps;
  25. IplImage* frame = cvQueryFrame(capture);
  26. if (!frame)
  27. {
  28. break;
  29. }
  30. cvShowImage("images", frame);
  31. IplImage* image = cvCloneImage(frame);
  32. cvSmooth(frame, image, CV_BLUR, 5, 5);
  33. for (int y = 0; y<image­>height; y++) // обнуление каналов данных
  34. {char *ptr = (uchar*)(image­>imageData + y*image­>widthStep);
  35. for (int x = 0; x < image­>width; x++)
  36. {
  37. ptr[3 * x + 2] = 0;
  38. ptr[3 * x + 2] = 0;
  39. }
  40. }
  41. cvShowImage("smooth", image);
  42. char c = cvWaitKey(33);
  43. if (c == 27)
  44. {
  45. cvReleaseImage(&image);
  46. break;
  47. }
  48. }
  49. QueryPerformanceCounter((LARGE_INTEGER *)& End);
  50. QueryPerformanceFrequency((LARGE_INTEGER *)& Freq);
  51. time = (End ­ Start) / Freq;
  52. std::cout << "fps : " << (int)(fps / time) << std::endl;
  53. cvReleaseCapture(&capture);
  54. cvDestroyWindow("images");
  55. cvDestroyWindow("smooth");
  56. std::cin.get();
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement