revisions 8681 and 8688 restored. Warning fixed.
Warning: changes beak binary compatibility
This commit is contained in:
55
samples/cpp/core_vision_tracking_image.cpp
Normal file
55
samples/cpp/core_vision_tracking_image.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <opencv2/core/core.hpp> // Basic OpenCV structures (cv::Mat, Scalar)
|
||||
#include <opencv2/highgui/highgui.hpp> // OpenCV window I/O
|
||||
#include <opencv2/core_vision_api/tracker.hpp>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
const string WindowName = "Face Detection example";
|
||||
const Scalar RectColor = CV_RGB(0,255,0);
|
||||
|
||||
int main()
|
||||
{
|
||||
namedWindow(WindowName);
|
||||
cv::moveWindow(WindowName, 100, 100);
|
||||
|
||||
Mat Viewport;
|
||||
Mat ReferenceFrame = imread("board.jpg");
|
||||
if (ReferenceFrame.empty())
|
||||
{
|
||||
printf("Error: Cannot load input image\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
cv::Ptr<nv::Tracker> tracker = nv::Algorithm::create<nv::Tracker>("nv::Tracker::OpticalFlow");
|
||||
|
||||
tracker->initialize();
|
||||
|
||||
// First frame for initialization
|
||||
tracker->feed(ReferenceFrame);
|
||||
|
||||
nv::Tracker::TrackedObjectHandler obj = tracker->addObject(cv::Rect(100,100, 200, 200));
|
||||
|
||||
while(true)
|
||||
{
|
||||
tracker->feed(ReferenceFrame);
|
||||
|
||||
if (obj->getStatus() == nv::Tracker::LOST_STATUS)
|
||||
break;
|
||||
|
||||
cv::Rect currentLocation = obj->getLocation();
|
||||
|
||||
ReferenceFrame.copyTo(Viewport);
|
||||
rectangle(Viewport, currentLocation, RectColor);
|
||||
|
||||
imshow(WindowName, Viewport);
|
||||
|
||||
if (cvWaitKey(30) >= 0) break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user