Commit a7301480 authored by artificiel's avatar artificiel
Browse files

async thread for CPU openCV processing

parent ebd20270
......@@ -3,6 +3,7 @@
#include <algorithm>
#include <functional>
#include <future>
#include "ofxFastFboReader.h"
#include "ofxHistogram.h"
......@@ -45,6 +46,13 @@ public:
{
ofPixels pixels;
reader_.readToPixels(fbo, pixels);
histo_stuff_ = async(launch::async, &ofxRGBVHistogram::perform_in_bg, this, pixels);
}
std::pair<bool, std::string> perform_in_bg(ofPixels pixels)
{
pthread_setname_np(pthread_self(), "histogram");
rgb_.setFromPixels(pixels);
cvCvtColor(rgb_.getCvImage(), hsv_.getCvImage(), CV_BGR2HSV);
......@@ -58,8 +66,11 @@ public:
// the hsv conversion is not cheap; this is a faster way to get a sense of the V
histogramV = histogramR + histogramG + histogramB;
return std::make_pair(true, "allo");
}
future<std::pair<bool, std::string>> histo_stuff_;
void draw(int x, int y, int w, int h)
{
ofPushMatrix();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment