5/06/2015

OpenCV300 rc1 - VideoCapture, imread example

This is Video capture example in ver. opencv 3.0 rc1.

In 3.0, location of functions are little changed.
In case of VideoCapture, we should include opencv_videoio300.lib.

So note to this source code for easy coding access.


#include < iostream>
#include < opencv2\opencv.hpp>
#include < opencv2\videoio.hpp>
#include < opencv2\highgui.hpp>

#ifdef _DEBUG           
#pragma comment(lib, "opencv_core300d.lib")   
#pragma comment(lib, "opencv_highgui300d.lib")
#pragma comment(lib, "opencv_videoio300d.lib")
#else   
#pragma comment(lib, "opencv_core300.lib")   
#pragma comment(lib, "opencv_highgui300.lib")
#pragma comment(lib, "opencv_videoio300.lib")
#endif    

using namespace std;
using namespace cv;
void main()
{
 
 Mat test;
 cv::VideoCapture cap("M:\\____videoSample____\\posco\\cartype1.avi");//0); 
 namedWindow("t");
 while(1)
 {
  cap >> test;
  if( test.empty() )
   break;

  imshow("t", test);

  if( waitKey(10) > 0)
   break;
 }
}



----

This is source code of using "imread" function. (need opencv_imgcodecs300.lib )

#include < iostream>
#include < opencv2\opencv.hpp>
#include < opencv2\highgui.hpp>
#include < opencv2\imgcodecs.hpp>

#ifdef _DEBUG           
#pragma comment(lib, "opencv_core300d.lib")   
#pragma comment(lib, "opencv_highgui300d.lib")
#pragma comment(lib, "opencv_imgcodecs300d.lib")
#else   
#pragma comment(lib, "opencv_core300.lib")   
#pragma comment(lib, "opencv_highgui300.lib")
#pragma comment(lib, "opencv_imgcodecs300.lib")
#endif    

using namespace std;
using namespace cv;
void main()
{
 
 Mat test;
 test = imread("M:\\____videoSample____\\torso\\Positive1.png");

 namedWindow("t");
 imshow("t", test);
 waitKey(0);

}





No comments:

Post a Comment