Last active
October 5, 2016 00:37
-
-
Save arccoder/651900108149529fc5e29dfd45115f60 to your computer and use it in GitHub Desktop.
How to use meanshift functionality from FastCV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "fastcv.h" | |
#include <opencv2/core/core.hpp> | |
#include <opencv2/highgui/highgui.hpp> | |
#include <iostream> | |
using namespace cv; | |
using namespace std; | |
int main() | |
{ | |
// Image dimensions | |
uint32_t srcWidth = 100; | |
uint32_t srcHeight = 100; | |
uint32_t srcStride = srcWidth; | |
// OpenCV - Create source image | |
Mat imageSrc = Mat( srcHeight, srcWidth, CV_8U); | |
imageSrc.setTo(0); | |
Rect r = Rect(40,40,50,50); | |
imageSrc(r).setTo(255); | |
// OpenCV - Display source image | |
imshow( "Source Image", imageSrc ); | |
waitKey(0); | |
// FastCV - Source data preparation | |
const uint8_t *__restrict src = imageSrc.data; | |
fcvRectangleInt window; | |
window.x = window.y = 1; | |
window.width = window.height = 50; | |
fcvTermCriteria criteria; | |
criteria.epsilon = 1; | |
criteria.max_iter = 100; | |
uint32_t output = | |
fcvMeanShiftu8 ( src, srcWidth, srcHeight, srcStride, &window, criteria); | |
cout << "Iterations : " << output << endl; | |
cout << "Rect : " << window.x << "," << window.y << "," << window.width << "," << window.height << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment