Exemple #1
0
int main(int argc, char **argv){

    ros::init(argc, argv, "stabtalker");
    ros::NodeHandle n;
    cameraData_pub = n.advertise<geometry_msgs::Twist>("qstab2/cameraData", 1000);

    VideoProcessor processor;
    qstab::FeatureTracker tracker;
    tracker.fix();
    tracker.setTrigger(mytrigger);
    processor.setInput(CV_CAP_ANY);
    processor.setFrameProcessor(&tracker);

    processor.setDelay(1000./processor.getFrameRate());
    ros::Rate loop_rate(10);

    if(processor.isOpened())
        while(ros::ok()) {
            if(!processor.runOnce()) break;
            ros::spinOnce();
            loop_rate.sleep();
        }


    return 1;
}
Exemple #2
0
int main(){

    VideoProcessor processor;
    FeatureTracker tracker;
    processor.setInput(CV_CAP_ANY);
    processor.setFrameProcessor(&tracker);
    processor.displayOutput("Tracked Features");
    processor.setDelay(1000./processor.getFrameRate());
    processor.run();

    return 1;
}
int main(int argc, char* argv[]) {

	VideoProcessor video;
	video.setInput("E:/BigData/2.avi");
	video.setWinName("input", "output");
	video.setDelay(40);
	ARDroneTracker tr;
	video.setProcessor(&tr);
	video.run();

	return 0;
}
Exemple #4
0
int main()
{
	VideoProcessor processor;
	processor.Init("images/output.avi");
	if (processor.SetInput("images/output.avi") != 0)
	{
		return -1;
	}
	
	processor.SetDelay(1);
	processor.DisplayInput("original image");
	processor.DisplayOutputFront("front image");
	processor.DisplayOutputBack("back image");

	clock_t t3, t4;
	t3 = clock();
	processor.Run();
	t4 = clock();
	cout << "×Üʱ¼ä£º" << (double)(t4 - t3) / CLOCKS_PER_SEC << std::endl;


	return 0;

}
int main()
{
	TestPerspective();	
	TestAffine();
	return 0;
	// Create video procesor instance
	VideoProcessor processor;
	
	// Create feature tracker instance
	MotionTracker tracker;
	//MCDBSProcessor tracker;
	//VibeProcessor tracker;
	std::vector<std::string> fileNames;
	for(int i=1; i<=1700;i++)
	{
		char name[50];
		sprintf(name,"..\\PTZ\\input0\\in%06d.jpg",i);
		//sprintf(name,"..\\PTZ\\input4\\drive1_%03d.png",i);
		fileNames.push_back(name);
	}
	// Open video file
	//processor.setInput(fileNames);
	processor.setInput("..\\MCD\\pets_2005_1.avi");
	// set frame processor
	processor.setFrameProcessor(&tracker);

	// Declare a window to display the video
	processor.displayOutput("Tracked Features");

	// Play the video at the original frame rate
	//processor.setDelay(1000./processor.getFrameRate());
	processor.setDelay(1000/25);

	// Start the process
	processor.run();

	cv::waitKey();

}
int main()
{
    // Open the video file
    cv::VideoCapture capture("../images/bike.avi");
    // check if video successfully opened
    if (!capture.isOpened())
        return 1;

    // Get the frame rate
    double rate = capture.get(cv::CAP_PROP_FPS);

    bool stop(false);
    cv::Mat frame; // current video frame
    cv::namedWindow("Extracted Frame");

    // Delay between each frame
    // corresponds to video frame rate
    int delay = 1000 / rate;

    // for all frames in video
    while (!stop)
    {

        // read next frame if any
        if (!capture.read(frame))
            break;

        cv::imshow("Extracted Frame", frame);

        // introduce a delay
        // or press key to stop
        if (cv::waitKey(delay) >= 0)
            stop = true;
    }

    // Close the video file
    capture.release();

    cv::waitKey();

    // Now using the VideoProcessor class

    // Create instance
    VideoProcessor processor;
    // Open video file
    processor.setInput("../images/bike.avi");
    // Declare a window to display the video
    processor.displayInput("Input Video");
    processor.displayOutput("Output Video");
    // Play the video at the original frame rate
    processor.setDelay(1000. / processor.getFrameRate());
    // Set the frame processor callback function
    processor.setFrameProcessor(canny);
    // Start the process
    processor.run();
    cv::waitKey();

    // Second test
    // Create instance
    //	VideoProcessor processor;
    // Open video file
    processor.setInput("../images/bike.avi");

    // Get basic info about video file
    cv::Size size = processor.getFrameSize();
    std::cout << size.width << " " << size.height << std::endl;
    std::cout << processor.getFrameRate() << std::endl;
    std::cout << processor.getTotalFrameCount() << std::endl;
    std::cout << processor.getFrameNumber() << std::endl;
    std::cout << processor.getPositionMS() << std::endl;

    // No processing
    processor.dontCallProcess();
    // Output filename
    //	processor.setOutput("bikeOut",".jpg");
    char codec[4];
    processor.setOutput("bike.avi", processor.getCodec(codec), processor.getFrameRate());
    std::cout << "Codec: " << codec[0] << codec[1] << codec[2] << codec[3] << std::endl;

    // Position the stream at frame 300
    //	processor.setFrameNumber(300);
    //	processor.stopAtFrameNo(120);

    // Declare a window to display the video
    processor.displayInput("Current Frame");
    processor.displayOutput("Output Frame");

    // Play the video at the original frame rate
    processor.setDelay(1000. / processor.getFrameRate());

    // Start the process
    processor.run();

    std::cout << processor.getFrameNumber() << std::endl;
    std::cout << processor.getPositionMS() << std::endl;

    cv::waitKey();
}
Exemple #7
0
int main()
{
	// Open the video file
    cv::VideoCapture capture("D://workspace//pictures//bike.avi");
	// check if video successfully opened
	if (!capture.isOpened())
		return 0;

	// current video frame
	cv::Mat frame; 
	// foreground binary image
	cv::Mat foreground;

	cv::namedWindow("Extracted Foreground");

	// The Mixture of Gaussian object
	// used with all default parameters
    //cv::BackgroundSubtractorMOG2 mog;
    cv::Ptr<cv::BackgroundSubtractor> mog;
    mog = cv::createBackgroundSubtractorMOG2();

	bool stop(false);
	// for all frames in video
	while (!stop) {

		// read next frame if any
		if (!capture.read(frame))
			break;

		// update the background
		// and return the foreground
//		mog(frame,foreground,0.01);
        mog->apply(frame, foreground, 0.01);


		// Complement the image
		cv::threshold(foreground,foreground,128,255,cv::THRESH_BINARY_INV);

		// show foreground
		cv::imshow("Extracted Foreground",foreground);

		// introduce a delay
		// or press key to stop
		if (cv::waitKey(10)>=0)
				stop= true;
	}

	cv::waitKey();

	// Create video procesor instance
	VideoProcessor processor;

	// Create background/foreground segmentor 
	BGFGSegmentor segmentor;
	segmentor.setThreshold(25);

	// Open video file
	processor.setInput("../bike.avi");

	// set frame processor
	processor.setFrameProcessor(&segmentor);

	// Declare a window to display the video
	processor.displayOutput("Extracted Foreground");

	// Play the video at the original frame rate
	processor.setDelay(1000./processor.getFrameRate());

	// Start the process
	processor.run();

	cv::waitKey();
}
Exemple #8
0
int main()
{
	VideoCapture capture("bike.avi");
	if (!capture.isOpened()) return 1;
	double rate = capture.get(CV_CAP_PROP_FPS);
	bool stop(false);
	Mat frame;
	namedWindow("Extractor Frame");
	int delay = 1000 / rate;
	while (!stop)
	{
		//if (!capture.read(frame)) break;
		capture >> frame;
		imshow("Extractor Frame", frame);
		//ÒýÈëÑÓ³Ù
		if (waitKey(delay) >= 0) stop = true;
	
	}
	capture.release();
	//test
	VideoCapture capture1;
	Mat frame1;
	capture1.open("bike.avi");
	namedWindow("test");
	while (!stop)
	{
		capture1 >> frame1;
		imshow("test", frame1);
		if (waitKey(delay) >= 0) stop = true;
	}
	int n = capture1.get(CV_CAP_PROP_FRAME_COUNT);
	cout << n << endl;
	capture1.release();
	//second test
	VideoProcessor process;
	process.setInput("bike.avi");
	process.displayInput("Input Video");
	process.displayOutput("Output Video");
	// Play the video at the original frame rate
	process.setDelay(1000. / process.getFrameRate());
	// Set the frame processor callback function
	process.setFrameprocessor(canny);
	process.run();
	waitKey();

	// Second test
	// Create instance
	//	VideoProcessor processor;
	// Open video file
	VideoProcessor1 processor;
	processor.setInput("bike.avi");
	// Get basic info about video file
	cv::Size size = processor.getFrameSize();
	std::cout << size.width << " " << size.height << std::endl;
	std::cout << processor.getFrameRate() << std::endl;
	std::cout << processor.getTotalFrameCount() << std::endl;
	std::cout << processor.getFrameNumber() << std::endl;
	std::cout << processor.getPositionMS() << std::endl;

	// No processing
	processor.dontCallProcess();
	// Output filename
	//	processor.setOutput("../output/bikeOut",".jpg");
	char codec[4];
	processor.setOutput("bike2.avi", processor.getCodec(codec), processor.getFrameRate());
	std::cout << "Codec: " << codec[0] << codec[1] << codec[2] << codec[3] << std::endl;

	// Position the stream at frame 300
	//	processor.setFrameNumber(300);
	//	processor.stopAtFrameNo(120);

	// Declare a window to display the video
	processor.displayInput("Current Frame");
	processor.displayOutput("Output Frame");

	// Play the video at the original frame rate
	processor.setDelay(1000. / processor.getFrameRate());

	// Start the process
	processor.run();

	std::cout << processor.getFrameNumber() << std::endl;
	std::cout << processor.getPositionMS() << std::endl;

	cv::waitKey();




}
int main()
{
	// Open the video file
	cv::VideoCapture capture("bike.avi");
//	cv::VideoCapture capture("http://www.laganiere.name/bike.avi");
	// check if video successfully opened
	if (!capture.isOpened())
		return 1;

	// Get the frame rate
	double rate= capture.get(CV_CAP_PROP_FPS);
	std::cout << "Frame rate: " << rate << "fps" << std::endl;

	bool stop(false);
	cv::Mat frame; // current video frame
	cv::namedWindow("Extracted Frame");

	// Delay between each frame
	// corresponds to video frame rate
	int delay= 1000/rate;
	long long i=0;
	std::string b="bike";
	std::string ext=".bmp";
	// for all frames in video
	while (!stop) {

		// read next frame if any
		if (!capture.read(frame))
			break;

		cv::imshow("Extra	cted Frame",frame);

		std::string name(b);
        // note: some MinGW compilers generate an error for this line
        // this is a compiler bug
        // try: std::ostringstream ss; ss << i; name+= ss.rdbuf(); i++;
//		name+=std::to_string(i++);
        std::ostringstream ss; ss << i; name+= ss.str(); i++;
		name+=ext;

		std::cout << name <<std::endl;
		
		cv::imwrite(name,frame);

		// introduce a delay
		// or press key to stop
		if (cv::waitKey(delay)>=0)
				stop= true;
	}

	// Close the video file
	capture.release();

	cv::waitKey();

	// Now using the VideoProcessor class

	// Create instance
	VideoProcessor processor;

	// Open video file
	processor.setInput("bike.avi");

	// Declare a window to display the video
	processor.displayInput("Input Video");
	processor.displayOutput("Output Video");

	// Play the video at the original frame rate
	processor.setDelay(1000./processor.getFrameRate());

	// Set the frame processor callback function
	processor.setFrameProcessor(canny);

	// output a video
	processor.setOutput("bikeCanny.avi",-1,15);

	// stop the process at this frame
	processor.stopAtFrameNo(51);

	// Start the process
	processor.run();

	cv::waitKey();	

	return 0;
}