Skip to content

Instantly share code, notes, and snippets.

@arccoder
Last active October 5, 2016 00:37
Show Gist options
  • Save arccoder/651900108149529fc5e29dfd45115f60 to your computer and use it in GitHub Desktop.
Save arccoder/651900108149529fc5e29dfd45115f60 to your computer and use it in GitHub Desktop.
How to use meanshift functionality from FastCV
#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