Guest User

Untitled

a guest
Jun 17th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. OpenCV running slow
  2. IplImage* DrawHistogram(CvHistogram *hist, float sX)
  3. {
  4. float histMax = 0;
  5. cvGetMinMaxHistValue(hist, 0, &histMax, 0, 0);
  6.  
  7. IplImage *imgHist = cvCreateImage(cvSize(256, 64), IPL_DEPTH_8U, 1);
  8. cvZero(imgHist);
  9.  
  10. float histValue = 0;
  11. float nextValue = 0;
  12. for (int i = 0; i < ((BINS - 1)*sX); i++)
  13. {
  14. histValue = cvQueryHistValue_1D(hist, i);
  15. nextValue = cvQueryHistValue_1D(hist, i + 1);
  16.  
  17. CvPoint p1 = cvPoint(i * sX, 64);
  18. CvPoint p2 = cvPoint((i + 1) * sX, 64);
  19. CvPoint p3 = cvPoint((i + 1) * sX, 64 - histValue*(64/histMax));
  20. CvPoint p4 = cvPoint(i * sX, 64 - histValue*(64/histMax));
  21.  
  22. int n = 5;
  23. CvPoint pts[] = {p1, p2, p3, p4};
  24.  
  25. cvFillConvexPoly(imgHist, pts, n, cvScalar(255));
  26. //cvFillPoly(imgHist, pts, &n, 1,cvScalar(255));
  27. }
  28.  
  29. return imgHist;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment