fixed writing video in HOG sample

This commit is contained in:
Alexey Spizhevoy 2011-01-14 08:08:02 +00:00
parent 3ce147bd94
commit ea01adb9c9

View File

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