/test/opencv/resample_test.cpp

https://gitlab.com/B3h3m0th/ccv · C++ · 28 lines · 24 code · 4 blank · 0 comment · 1 complexity · 31b6c156d7df7b9292035ffab7c1ae7b MD5 · raw file

  1. #include "cv.h"
  2. #include "highgui.h"
  3. #include <assert.h>
  4. #include <stdio.h>
  5. #include <sys/time.h>
  6. unsigned int get_current_time()
  7. {
  8. struct timeval tv;
  9. gettimeofday(&tv, NULL);
  10. return tv.tv_sec * 1000 + tv.tv_usec / 1000;
  11. }
  12. int main(int argc, char** argv)
  13. {
  14. assert(argc == 3);
  15. IplImage* image = cvLoadImage(argv[1]);
  16. CvMat* x = cvCreateMat((int)(image->height / 1.414), (int)(image->width / 1.414), CV_8UC3);
  17. unsigned int elapsed_time = get_current_time();
  18. cvResize(image, x, CV_INTER_AREA);
  19. printf("elapsed time : %d\n", get_current_time() - elapsed_time);
  20. cvSaveImage(argv[2], x);
  21. cvReleaseMat(&x);
  22. cvReleaseImage(&image);
  23. return 0;
  24. }