Merge remote-tracking branch 'origin/2.4' into merge-2.4
[profile/ivi/opencv.git] / samples / cpp / Qt_sample / main.cpp
index 8794539..92bc2b5 100644 (file)
@@ -4,7 +4,11 @@
 
 #include <iostream>
 #include <vector>
-#include <opencv2/highgui/highgui.hpp>
+#include <opencv2/core/core_c.h>
+#include <opencv2/calib3d/calib3d_c.h>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+#include <opencv2/legacy/compat.hpp>
 
 #if defined WIN32 || defined _WIN32 || defined WINCE
     #include <windows.h>
@@ -20,8 +24,6 @@
     #include <GL/gl.h>
 #endif
 
-#include <opencv2/core/core.hpp>
-
 using namespace std;
 using namespace cv;
 
@@ -117,12 +119,9 @@ static void foundCorners(vector<CvPoint2D32f> *srcImagePoints, const Mat& source
     normalize(grayImage, grayImage, 0, 255, NORM_MINMAX);
     threshold(grayImage, grayImage, 26, 255, THRESH_BINARY_INV); //25
 
-    Mat MgrayImage = grayImage;
-    //For debug
-    //MgrayImage = MgrayImage.clone();//deep copy
     vector<vector<Point> > contours;
     vector<Vec4i> hierarchy;
-    findContours(MgrayImage, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
+    findContours(grayImage, contours, hierarchy, RETR_EXTERNAL, CHAIN_APPROX_NONE);
 
     Point p;
     vector<CvPoint2D32f> srcImagePoints_temp(4,cvPoint2D32f(0,0));
@@ -193,7 +192,7 @@ static void foundCorners(vector<CvPoint2D32f> *srcImagePoints, const Mat& source
             ss.str("");
 
             //new coordinate system in the middle of the frame and reversed (camera coordinate system)
-            srcImagePoints->at(i) = cvPoint2D32f(srcImagePoints_temp.at(i).x-source->width/2,source->height/2-srcImagePoints_temp.at(i).y);
+            srcImagePoints->at(i) = cvPoint2D32f(srcImagePoints_temp.at(i).x-source.cols/2,source.rows/2-srcImagePoints_temp.at(i).y);
         }
     }
 
@@ -230,8 +229,8 @@ int main(void)
 
     video >> source;
 
-    namedWindow("original", WINDOW_AUTOSIZE | CV_WINDOW_FREERATIO);
-    namedWindow("POSIT", WINDOW_AUTOSIZE | CV_WINDOW_FREERATIO);
+    namedWindow("original", WINDOW_AUTOSIZE | WINDOW_FREERATIO);
+    namedWindow("POSIT", WINDOW_AUTOSIZE | WINDOW_FREERATIO);
     displayOverlay("POSIT", "We lost the 4 corners' detection quite often (the red circles disappear). This demo is only to illustrate how to use OpenGL callback.\n -- Press ESC to exit.", 10000);
 
     float OpenGLMatrix[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
@@ -255,14 +254,14 @@ int main(void)
         video >> source;
         imshow("original",source);
 
-        foundCorners(&srcImagePoints,source,grayImage);
+        foundCorners(&srcImagePoints, source, grayImage);
         cvPOSIT( positObject, &srcImagePoints[0], FOCAL_LENGTH, criteria, rotation_matrix, translation_vector );
         createOpenGLMatrixFrom(OpenGLMatrix,rotation_matrix,translation_vector);
 
         imshow("POSIT",source);
 
-        if (VideoCapture::get(video,CV_CAP_PROP_POS_AVI_RATIO)>0.99)
-            VideoCapture::get(video,CV_CAP_PROP_POS_AVI_RATIO,0);
+        if (video.get(CAP_PROP_POS_AVI_RATIO) > 0.99)
+            video.set(CAP_PROP_POS_AVI_RATIO, 0);
     }
 
     destroyAllWindows();