PageRenderTime 61ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/Exercises/warp/main.cpp

https://github.com/twelly/OpenCV
C++ | 28 lines | 25 code | 1 blank | 2 comment | 4 complexity | d28b2063537a41a3cae871e3389894bf MD5 | raw file
  1. // Usage: warp <image>
  2. //
  3. #include <cv.h>
  4. #include <highgui.h>
  5. int main(int argc, char** argv)
  6. {
  7. CvMat* warp_matrix = cvCreateMat(3,3,CV_32FC1);
  8. IplImage *src, *dst;
  9. float mat_test[4][2] = {96.0f,236.0f,226.0f,305.0f,408.0f,94.0f,498.0f,106.0f};
  10. float mat_test2[4][2] = {98.0f,231.0f,225.0f,306.0f,410.0f,94.0f,498.0f,106.0f};
  11. if( argc == 2 && ((src=cvLoadImage(argv[1],1)) != 0 ))
  12. {
  13. dst = cvCloneImage(src);
  14. cvZero(dst);
  15. dst->origin = src->origin;
  16. cvInitMatHeader(&src_mat, 4,2, CV_32FC1,mat_test);
  17. cvInitMatHeader(&dst_mat, 4,2, CV_32FC1,mat_test2);
  18. cvFindHomography(&src_mat, &dst_mat, warp_matrix);
  19. cvWarpPerspective(src, dst, transform);
  20. cvNamedWindow("Perspective_Warp", 1);
  21. cvShowImage("Perspective_Warp", dst);
  22. cvWaitKey();
  23. }
  24. cvReleaseImage(&dst);
  25. cvReleaseMat(&warp_matrix);
  26. return 0;
  27. }