Quantcast
Channel: beginners - openFrameworks
Viewing all 4929 articles
Browse latest View live

Expression: vector iterator not incrementable

$
0
0

@jbacelar wrote:

Hi.

Please, I came from processing quite recently to OF.
Need some help debugging a mac working project to a windows compilation:

This code adds menu names from vector selected2. It´s working fine on xCode but VisualStudio says
vector iterator not incrementable when at mouseReleased from the ofxUI function.

string name2 = e.widget->getName();
ofxUIToggle *toggle2 = (ofxUIToggle *)e.widget;
ddl2->setShowCurrentSelected(toggle2->getValue());

if (name2 == "Ramos de Atividade")
{
	ofxUIDropDownList *ddlist2 = (ofxUIDropDownList *)e.widget;
	vector<ofxUIWidget *> &selected2 = ddlist2->getSelected();

	for (int i = 0; i < selected2.size(); i++)
	{
		nameToMenu = selected2[i]->getName();
	}


	if (g_img_N == 1 && g_changeMenu == true) {

		ddl2->clearToggles();

		string add= "";
		std::set<std::string>::iterator it_names = RArtLar.v_setRamos.begin();

		for (int i = 0; i< RArtLar.maxElements; i++) {

			add+= *it_names;
			ddl2->addToggle(*it_names);
			// cout << "*it_names : " << *it_names << endl;
			add+= "\n";
			it_names++;

		}
		g_changeMenu = false;
	}

Posts: 5

Participants: 2

Read full topic


Simple 2D top-down camera

$
0
0

@Maros_Betko wrote:

Hi,
I'm currently working on a project that is using 2D top-down view and draws everything into one grid. What I need now is a way to move around this "map". After searching for solution I found only tutorials for ofEasyCam which is not what I need. I've also tried using ofTranslate to move the view but for some to me unknown reason whenever I move the view so left-top most corner of my grid goes out of window, everything dissapears.
I'm in a bit of hurry so I would be really grateful for fast answers.
Thank you.

Posts: 3

Participants: 2

Read full topic

Shader with fbo texture

$
0
0

@nami wrote:

// Sorry. I am Japanese programmer. So, my English is not good enough.

I want to use the texture which the previous fbo create. But I can't get texture data in the shader.
I can not explain it well, so please read the following code.

ofApp.cpp

void ofApp::setup(){
    u_mouse = ofVec2f(0,0);
    ofSetBackgroundColor(0);
    ofSetWindowShape(1024, 1024);

    ofSetBoxResolution(1000);
    ofSetVerticalSync(false);

    dir.open("");
    dir.allowExt("frag");
    dir.listDir();

   fbo.allocate(ofGetWidth(), ofGetHeight());
   texture.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA);
}

//--------------------------------------------------------------
void ofApp::draw(){
    fbo.begin();

    shader.load("", "frag.frag");

    shader.begin();
    shader.setUniform1f("u_time", save_time + ofGetElapsedTimef());
    shader.setUniform2f("u_resolution", ofGetWidth(), ofGetHeight());
    shader.setUniformTexture("texture", texture, 0);

    ofFill();
    ofDrawRectangle(0,0,ofGetWidth(), ofGetHeight());
    shader.end();
    fbo.end();

    fbo.draw(0, 0);
    texture = fbo.getTexture();
}

frag.frag

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 u_resolution;
uniform float u_time;
uniform sampler2D texture;

vec2 vInvert( vec2 _st ) {
    return vec2( 0.0, 1.0 ) + vec2( 1.0, -1.0 ) * _st;
}

void main(void){
    vec2 st = gl_FragCoord.xy / u_resolution.xy;

    vec3 color = vec3(0.);
    if (u_time <= 3.) {
        color = vec3(1.);
    }
    color += texture2D(texture, vInvert(st)).xyz;
    gl_FragColor = vec4(color, 1.);
}

I think if the texture data is sent correctly by ofApp.cpp to the shader, the result will be white forever.

Can anybody help me?

Posts: 4

Participants: 3

Read full topic

Smooth or blur image edges using opencv

$
0
0

@Omer_Aslam wrote:

I want to feathere smooth or blur image edges using opencv.

This is what i tried

int lowThreshold = 100;
int ratio = 3;
int kernelSize = 3;

Mat srcGray, cannyEdges, blurred;
cvtColor(input, srcGray, CV_BGR2GRAY);
blur(srcGray, cannyEdges, Size(3, 3));
Canny(cannyEdges, cannyEdges, lowThreshold, lowThreshold * ratio, kernelSize);

int dilation_size = 5;
Mat element = getStructuringElement(MORPH_CROSS,
                            Size(2 * dilation_size + 1, 2 * dilation_size + 1),
                            Point(dilation_size, dilation_size));

dilate(cannyEdges, cannyEdges, element);
input.copyTo(blurred);
blur(blurred, blurred, Size(3, 3));
blurred.copyTo(output, cannyEdges);

This is the image of my input, my output and desired result

please tell me how can i achieve desired result

Posts: 1

Participants: 1

Read full topic

^ Received error ^ when install dependencies

$
0
0

@baydam wrote:

I've download the OF 0.9.8 version and got an error during install
ranlib /opt/openFrameworks/scripts/apothecary/build/poco/lib/Linux/x86_64/libPocoNet.a
make[1]: Leaving directory '/opt/openFrameworks/scripts/apothecary/build/poco/Net'

Posts: 3

Participants: 2

Read full topic

Color Gradients and Tone Map

Saving stream of floats on txt file

$
0
0

@antocreo wrote:

Hi everyone,
I am having hard time figure out how to save a stream of real-time floats coming from a device to a txt file.
I need the txt file to be very simple e.g.

1.
4.
5.
6.

etc... I tried with ofLog but the file saved contain also other information I can't exclude.
I am trying with ofFile and ofBuffer but it doesn't seem I can make it work nicely.
More specifically, I created an array of ofFIle, but I don't understand how to assign a different file name to each file...

Any hint? I feel like there's a simple solution but I can't find it yet..

Thank you!

Posts: 3

Participants: 2

Read full topic

Printing visuals on paper. Solution : export to SVG?

$
0
0

@celinechappert wrote:

Hi everyone,

I'm wondering about the possibility of printing on paper some of the visuals I have been working on. I would like to get prints done about 2 meters x 1 meter, about human scale. I have thought about a couple options to do this, and while exporting PNG stills wouldn't work for resolution purposes, I'm guessing a solution would be an SVG export maybe ?

I haven't found much information on this though, has anyone encountered this before or can recommend a tool or a trick ?

Thanks !

Posts: 1

Participants: 1

Read full topic


Accentuated character strings

$
0
0

@Gallo wrote:

Hello,

I know this problem has already been discussed but i can't find any solution.

I need to display special (accentuated) characters but compiler complains with a warning : illegal character encoding in string literal and the character is not displayed.

font.drawString("î é", 300, 550);

i know this is a character encoding issue, but how could i solve it ?

thanks a lot

Posts: 1

Participants: 1

Read full topic

Listen to ofEvent ofxPanel::savePressedE

$
0
0

@Biquetto wrote:

Hello,

I'm looking for implement a event listener for the following event in order to prevent it in some case but I'm unable to make it works.

ofEvent ofxPanel::savePressedE

Can somebody explain me to implement such event handler function in .h & .cpp files ?

Regards

Posts: 1

Participants: 1

Read full topic

Cannot load model

$
0
0

@edapx wrote:

I've a problem loading an external model to OF. I've tried first loading the mesh using a .ply file:

//in the header
ofVboMesh mesh;
//in the setup call
mesh.load('example.ply');

//in the draw call
mesh.draw();

And as error I've:

[ error ] ofMesh: load(): 2367:face not a triangle
[ error ] ofMesh: load(): "4 0 1 2 3"

I've then making another attempt exporting the file as `3ds` and loading it with ofxAssimpLoader:

// in the header
#include "ofxAssimpModelLoader.h"
ofxAssimpModelLoader trunk;


void ofApp::setup(){
  trunk.loadModel("trunk.3ds", 20);
}

void ofApp::draw(){
  trunk.drawFaces();
}

And this is the error:

[ error ] ofShader: setupShaderFromSource(): GL_VERTEX_SHADER shader failed to compile
[ error ] ofShader: GL_VERTEX_SHADER shader reports:
ERROR: 0:14: '' : syntax error: incorrect preprocessor directive
ERROR: 0:14: '' : syntax error: unexpected tokens following #if preprocessor directive - expected a newline
ERROR: 0:40: '' : syntax error: incorrect preprocessor directive
ERROR: 0:40: '' : syntax error: unexpected tokens following #if preprocessor directive - expected a newline

[ error ] ofShader: GL_VERTEX_SHADER, offending line 14 :
	   12	OUT vec3 v_eyePosition;
	   13	OUT vec3 v_worldPosition;
	   14	#if HAS_COLOR
	   15	OUT vec4 v_color;
	   16	#endif

Im on OSX El Capitan, and I'm using the programmable pipeline, this is mt main call:

int main( ){
    ofGLWindowSettings settings;
    settings.setGLVersion(3, 2);  // Programmable pipeline
    settings.width = 1024;
    settings.height = 1024;
    ofCreateWindow(settings);
    if(!ofGLCheckExtension("GL_ARB_geometry_shader4") && !ofGLCheckExtension("GL_EXT_geometry_shader4") && !ofIsGLProgrammableRenderer()){
        ofLogFatalError() << "geometry shaders not supported on this graphics card";
        return 1;
    }
}

Posts: 4

Participants: 2

Read full topic

Can anyone please explain the flow of this code. (Beginner)

I am not able to install openframework using msys2

$
0
0

@pratvala wrote:

I installed msy2 and qtcreator for my windows7 64bit os.
also done all the step as per
http://openframeworks.cc/setup/msys2/
for msys2
and

but still i'm not able to get the result from this like showed in this video

http://openframeworks.cc/setup/qtcreator/

please please please help me i'm new in this

but i want to play transparent or alpha video with my logitech camera so that's why i'm running the code.

Thank you so much in advance

if any one have done the all thing for windows please show me the step video is best for me.

Posts: 1

Participants: 1

Read full topic

Best practices for developing OF using git?

$
0
0

@aaa wrote:

Hey all,

Working on a lightweight projection mapping application that can run on a zero (and above, of course).

I'm switching between osx and the pi, mostly to dev on the mac for speed, and then test on the pi. When I try to run the project on a pi after downloading from git, it throws some errors (apologies, typing this away from that terminal, I can find out exact error messages if needed later).

It does work, however, if I manually copy over the src folder into an empty project and then update all of the files using nano, just type a space at the end of the file or whatever, and then make && make run again.

Ideas?

Posts: 1

Participants: 1

Read full topic

Multi Windows, open/close it programatically. Is there a way?

$
0
0

@Joao wrote:

Hi guys,

Been looking to the new multi window feature in OF for a possible project. It's pretty cool that now you can set multiple windows so easily.

I just wonder one thing, after closing the window is there a way to open it again programatically?

Thanks,
João

Posts: 1

Participants: 1

Read full topic


Agents in oF : different methods from Processing?

$
0
0

@celinechappert wrote:

Hi,

OpenFrameworks newbie here. I'm learning the methods by converting Processing sketches into oF.
I found a great sketch from Processing which randomly generates a group of agents and sets their direction in one of eight directions while incrementing their x and y positions. Since the sketch doesn't have any dependencies I thought I would have fun and try to translate it into oF. Full (Processing) code is here.

My problem is that the output visuals from Processing and openFrameworks are completely different (see pictures), and I can't figure out why.

Here is my code in oF -

In the .cpp file -

float posX;
float posY;

void ofApp::setup() {

ofSetBackgroundColor(255);
posX = ofGetWidth()/2; // centering position to center of screen
posY = ofGetHeight()/2;

}

void ofApp::draw(){

int north = 0;
int north_east = 1;
int east = 2;
int south_east = 3;
int south = 4;
int south_west = 5;
int west = 6;
int north_west = 7;

float step_size = 1;
int direction;


for (int i=0; i<=ofGetMouseX(); i++) {

    direction = (int) ofRandom(0, 8);

    if (direction == north) {

        posY -= step_size;

    }
    else if (direction == north_east) {
        posX += step_size;
        posY -= step_size;
    }
    else if (direction == east) {
        posX += step_size;
    }
    else if (direction == south_east) {
        posX += step_size;
        posY += step_size;
    }
    else if (direction == south) {
        posY += step_size;
    }
    else if (direction == south_west) {
        posX -=  step_size;
        posY -= step_size;
    }
    else if (direction == west) {
        posX -= step_size;
    }
    else if (direction == north_west) {
        posX -= step_size;
        posY -= step_size;
    }

    // if agent flies off screen
    if (posX > ofGetWidth()) posX = 0;
    if (posX < 0) posX = ofGetWidth();
    if (posY < 0) posY = ofGetHeight();
    if (posY > ofGetHeight()) posY = 0;


 ofSetColor(255, 0, 0);
 ofDrawEllipse(posX+step_size/2, posY+step_size/2, 1, 1);

}

What I've tried so far -

  • Checked that the returned values of posX and posY are the same between Processing/oF. The math is produces the same results. Basically it returns the width or height of the screen, divided by 2, plus 0.5.

  • Tried placing my variables in the .h file as well. Produces no different results.

Below is the openFrameworks output - these shapes shoot up in a Y axis manner.

Below is the Processing output - beautifully generated agents.

... you see, it looks like the Processing sketch keeps traces of the agents, whereas the oF one does not.

Halp !

The only thing I can think of, is that the ellipse() method in processing works differently from the ofDrawEllipse() method in oF. Can anyone can shed a bit of light on the situation ? I thought I was getting the hang of it :confused:

Posts: 1

Participants: 1

Read full topic

Help for merge 2 softwares

$
0
0

@cristian wrote:

Hello community,

I am just starting programming in OF and would like to ask for your help in a project. I need to merge 2 softwares and create a platform so that instead of running the 2 programs separately, I run the platform and fulfill the function of both softwares alone (I do not know if I expressed myself well). If you can guide me on how to start or some tutorials on the web, I would be very grateful.

Regards!

Posts: 1

Participants: 1

Read full topic

Secure TCP Sockets

$
0
0

@nickhubben wrote:

I need to convert a working project using ofxTCPServer/Client to a more secure method and will admit to having limited knowledge on the topic of SSL, HTTPS, etc.

Is there an existing method for using HTTPS with ofxTCPServer? Should I convert my app to use ofxHTTP instead?

Project is for Windows 10 if it matters.

Any advice is welcomed! TIA!

Posts: 1

Participants: 1

Read full topic

3d model over background image

$
0
0

@nosarious wrote:

I saw this question here, but I don't think it answered the same thing. (https://forum.openframeworks.cc/t/ofenabledepthtest-and-png-ofimage/17205 )

I have some objects I would like to place in a 'room'. The room is a photograph of the inside of a store front undergoing renovations. I would like to render som e3f shapes as if the are 'floating' in the room. I was hoping to use an easy cam to get the 3d scene lined up over the image.

I cannot seem to be able to display the 3d image overtop of the 2d image. It 'feels' similar to the question I saw earlier, but I was wondering if I should render the 3d image to an FBO with transparency and then just display that over top of the background? I understand that this may affect frame rates, however.

Since the room has items within it (poles, boxes, pillars, railings) the floating objects have to be able go in front of them or behind them, so I will be adding models within the screen and adding the background image as a texture to the stationary objects so they mimic reality. I'm just having trouble displaying that background image...

Posts: 1

Participants: 1

Read full topic

ofPath.translate() or what is the best way to move a complete ofpath

$
0
0

@nanu_c wrote:

I have some shiny ghosts defined as ofpath

And I want them to fly independently around. I have a class ghosts.h with a draw() function. They are added to the main program with an vector.

typedef shared_ptr<ghosts> ghosts_ptr;
vector<ghosts_ptr> theGhosts;

in the draw() of the ghosts I tried pos=pos+ofPoint(1,1,0); ghostBody.translate(pos); this is in the beginning the upperleft point and this results in some strange behavior. The ghost is repeating itself in a great distance and I couldn't find any documentation about this topic


So what is the best way to move an ofpath or should I use ofNode or smth. like that -> by now I am not so god in 3d graphics. Thanks

Posts: 1

Participants: 1

Read full topic

Viewing all 4929 articles
Browse latest View live