Neural Networkベースのトラッキング手法GOTURNを使ってみる
DRANK
#include <iostream>#include <opencv2/opencv.hpp>#include <opencv2/tracking.hpp>#include <opencv2/core/ocl.hpp>usingnamespacecv;usingnamespacestd;// Convert to string#define SSTR( x ) static_cast< std::ostringstream & >( \(std::ostringstream()<<std::dec<<x)).str()intmain(){ // Create a tracker Ptr<Tracker>tracker=TrackerGOTURN::create(); // Read video VideoCapturevideo("/path/to/video"); // Exit if video is not opened if(!video.isOpened()){ cout<<"Could not read video file"<<endl; return1; } // Read first frame Matframe; boolok=video.read(frame); // Define initial boundibg box Rect2dbbox(287,23,86,320); // Uncomment the line below to select a different bounding box bbox=selectROI(frame,false); // Display bounding box. rectangle(frame,bbox,Scalar(255,0,0),2,1); imshow("Tracking",frame); tracker->init(frame,bbox); while(video.read(frame)){ // Start timer doubletimer=(double)getTickCount(); // Upda…