openframeworks

How to interpolate a color sequence?

為{幸葍}努か 提交于 2019-12-17 19:30:05
问题 I need to interpolate or change gradually a sequence of colors, so it goes from colorA to colorB to colorC to colorD and them back to colorA, this need to be based on time elapsed in milliseconds, any help will be much appreciated (algorithms, pseudo code will be great). Note that I am working with RGB, it could be 0-255 or 0.0-1.0 range. This is what I have so far, I need to change the colors on every "timePeriod", them I calculate the percentage of time elapsed and change the colors, the

Vector.erase(Iterator) causes bad memory access

心不动则不痛 提交于 2019-12-17 13:46:04
问题 I am trying to do a Z-Index reordering of videoObjects stored in a vector . The plan is to identify the videoObject which is going to be put on the first position of the vector , erase it and then insert it at the first position. Unfortunately the erase() function always causes bad memory access. Here is my code: testApp.h: vector<videoObject> videoObjects; vector<videoObject>::iterator itVid; testApp.cpp: // Get the videoObject which relates to the user event for(itVid = videoObjects.begin()

Vector.erase(Iterator) causes bad memory access

六眼飞鱼酱① 提交于 2019-12-17 13:45:08
问题 I am trying to do a Z-Index reordering of videoObjects stored in a vector . The plan is to identify the videoObject which is going to be put on the first position of the vector , erase it and then insert it at the first position. Unfortunately the erase() function always causes bad memory access. Here is my code: testApp.h: vector<videoObject> videoObjects; vector<videoObject>::iterator itVid; testApp.cpp: // Get the videoObject which relates to the user event for(itVid = videoObjects.begin()

Openframeworks - rotate an image from its center through OpenGL calls

匆匆过客 提交于 2019-12-13 06:26:59
问题 I'm using openframeworks (which renders through OpenGL) and I'm trying to rotate an image from it's center. I know I should use ofRotate() and ofTranslate() but I haven't managed to figure it out by myself. Here's what I've tried so far: ofPushMatrix(); ofRotate(ofRandom(10),0.0,0.0,1.0); leafImg.draw(100,100); ofPopMatrix(); 回答1: Without doing too much math you can use a nested coordinate system offset the image so that when you rotate, you rotate from the centre. In short you'll be doing

creating a bounding box around a field of optical flow paths

依然范特西╮ 提交于 2019-12-12 18:02:37
问题 I have used cv::calcOpticalFlowFarneback to calculate the optical flow in the current and previous frames of video with ofxOpenCv in openFrameworks. I then draw the video with the optical flow field on top and then draw vectors showing the flow of motion in areas that are above a certain threshold. What I want to do now is create a bounding box of those areas of motion and get the centroid and store that x , y position in a variable for tracking. This is how I'm drawing my flow field if that

Loading ONI: Can’t create any node of the requested type

五迷三道 提交于 2019-12-12 04:18:42
问题 I am working on OpenFrameworks with the addon ofxOpenNI by gameoverhack. I got the addon successfully running on my Mac OS X El Capitan 10.11.2 with xCode 7.2. For those of you who have previously used this addon, you must be knowing that there are several examples provided with the addon, including one with simple ONI recording. I had an old ONI file recorded on my linux system and I tried to run it on the OS X installation. I got the following errors: [notice ] ofxOpenNIDevice[1]: Starting

New to C++, “EXC_BAD_ACCESS” error I don't understand

最后都变了- 提交于 2019-12-12 03:27:38
问题 I am attempting to translate a 2 dimensional cellular automata from Processing to openFrameworks (C++). I have written classes for the cells and for the game of life functionality. The application builds successfully but crashes immediately with the following error: Thread 1: Program received signal: "EXC_BAD_ACCESS". Here's my the header of my game of life class #include "Cell.h" class GoL { public: GoL(); void init(); void generate(); void display(); void run(); int w = 20; int cols; int

How to draw square with HSV color in OpenFrameworks / OpenCV

半城伤御伤魂 提交于 2019-12-11 18:45:22
问题 I have a OpenFrameworks project that is using OpenCv. I have histogram of the hue and saturation values of my image. To show the histogram I am drawing a grid of gray square's based on the values from the histogram. To make it easier to understand I want to draw a box under each grid column the hue that it represents. But given the HSV values how do I specify the color to draw the box? Normally you would use ofSetColor or ofSetHexColor but those are RGB based, and I dont know the RGB values.

Hit testing between four rotating vertices

蓝咒 提交于 2019-12-11 15:13:13
问题 I have a simple rectangle here in my program on which I had to do hit testing. I am using openFrameworks but I think the problem here is related to OpenGL topics as well. public class Shape : public class ofNode { Shape() { container.setFromCenter(getPosition(), 200,100); setPosition(ofVec3f(365, 50, 0)); //set the position of the node lookAt(ofVec3f(0,0,0)); } virtual void draw() { ofRect(container); //the 200/100 rectangle will be drawn as per the container position and dimensions } ofVec3f

Undefined reference to wpa_ctrl functions in my C++ OpenFrameworks project. Need help integrating this c library

独自空忆成欢 提交于 2019-12-11 13:30:40
问题 I'm working on a menu option to connect to wifi in my C++ application that is build using OpenFrameworks. I want to use the wpa_ctrl library but I can't get it to compile. Code snippet: NetworkWrapper.h: #ifndef NETWORKWRAPPER_H_ #define NETWORKWRAPPER_H_ class NetworkWrapper { public: NetworkWrapper(): private: struct wpa_ctrl* m_ctrl; }; #endif NetworkWrapper.cpp: #include "NetworkWrapper.h" extern "C" { #include "wpa_ctrl.h" } NetworkWrapper::NetworkWrapper() { m_ctrl = wpa_ctrl_open(