fixed writing video in HOG sample
authorAlexey Spizhevoy <no@email>
Fri, 14 Jan 2011 08:08:02 +0000 (08:08 +0000)
committerAlexey Spizhevoy <no@email>
Fri, 14 Jan 2011 08:08:02 +0000 (08:08 +0000)
samples/gpu/hog.cpp

index 81d61b0..8449004 100644 (file)
@@ -288,7 +288,7 @@ void App::run()
             // Change format of the image\r
             if (make_gray) cvtColor(frame, img_aux, CV_BGR2GRAY);\r
             else if (use_gpu) cvtColor(frame, img_aux, CV_BGR2BGRA);\r
-            else img_aux = frame;\r
+            else frame.copyTo(img_aux);\r
 \r
             // Resize image\r
             if (args.resize_src) resize(img_aux, img, Size(args.width, args.height));\r
@@ -326,7 +326,6 @@ void App::run()
             putText(img_to_show, "FPS (HOG only): " + hogWorkFps(), Point(5, 65), FONT_HERSHEY_SIMPLEX, 1., Scalar(255, 100, 0), 2);\r
             putText(img_to_show, "FPS (total): " + workFps(), Point(5, 105), FONT_HERSHEY_SIMPLEX, 1., Scalar(255, 100, 0), 2);\r
             imshow("opencv_gpu_hog", img_to_show);\r
-            handleKey((char)waitKey(3));\r
 \r
             if (args.src_is_video || args.src_is_camera) vc >> frame;\r
 \r
@@ -341,9 +340,14 @@ void App::run()
                     if (!video_writer.isOpened())\r
                         throw std::runtime_error("can't create video writer");\r
                 }\r
-                cvtColor(img_to_show, img, CV_BGRA2BGR);\r
+\r
+                if (make_gray) cvtColor(img_to_show, img, CV_GRAY2BGR);\r
+                else cvtColor(img_to_show, img, CV_BGRA2BGR);\r
+\r
                 video_writer << img;\r
             }\r
+\r
+            handleKey((char)waitKey(3));\r
         }\r
     }\r
 }\r