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

ofxOsc ofxGui | how to ofxToggle and ofxButton

$
0
0

@novas_fronteiras wrote:

hi everyone!

i tried for some time but couldnt being able to receive a message by osc to start a ofxToggle or ofxButton (inside ofxPanel). With ofParameters it is working fine, but just for the toggles / buttons it doesnt work.

does anyone has any hint on how to do it?

below is the code that i am using to control ofParameter with osc messages, and what i thought would work with ofxToggle:

OFAPP::SETUP

sender.setup("192.168.0.100", 8000);
receiver.setup(9000);

OFAPP::UPDATE

ofxOscMessage r;
r.setAddress("/red1");
r.addFloatArg(red); // ofParameter<float> red;
sender.sendMessage(r, false);

//that is what i thought would work with ofxToggle
ofxOscMessage p;
p.setAddress("/pause");    
p.addBoolArg(pause); // ofxToggle pause OR ofxButton pause;
sender.sendMessage(p, false);

thank you!

Posts: 1

Participants: 1

Read full topic


3D FFT Ocean Wave using OF

"No matching function for call to 'ListBox'"

$
0
0

@bemoregt wrote:

Hi, All.

“No matching function for call to ‘ListBox’”.

I met this error when run this ImGui code.

// ofApp.h
vector<std::string> scores;
		int indexScore;

// ofApp.cpp setup()
for (int i = 0; i < 100; i++) {
	scores.emplace_back("Score - " + ofToString(i));
}

// draw()
    ImGui::Begin("Scores");
	ImGui::ListBox("##scores", &indexScore, scores); // ## no label
	ImGui::End();

What’s wrong to me ??

Thanks.

Posts: 1

Participants: 1

Read full topic

I want to convert this "Processing code" to OF code

$
0
0

@bemoregt wrote:

Hi, All.

I want to convert this “Processing code” to OF code.

images
It’s a realtime audio spectrum using 3D disappearing to backward.
github: https://github.com/Hollenbeckj/ProcessingMusicVisualizer

How Can I convert?

import ddf.minim.;
import ddf.minim.signals.
;
import ddf.minim.analysis.*;
visualizer classicVi;

Minim minim;
FFT fft;

AudioOutput out;
AudioPlayer mp3;

PFont directions;
PImage fade;
float rWidth,rHeight;
int hVal;

boolean started; //boolean for telling if the program has started
boolean selection; //boolean for telling if a song has been selected
boolean canPlay;//boolean for allowing the audio to play
boolean canPauseAndPlay; //boolean for allowing the pause and play function
PImage title;//Image etup for the title screen

void setup()
{
//program setup
size(900,500,P3D);
title = loadImage(“VisualZtitle .png”);
frameRate(60);
started = false;
selection = false;

// sound and minim setup parameters
minim = new Minim(this);
mp3 = minim.loadFile(“mashUp.mp3”,2048);// load your mp3 file here make sure you use processing’s built in add file feature and type the name of the loaded mp3 inside the quotation marks
out = minim.getLineOut(Minim.STEREO,44100);
fft = new FFT(mp3.bufferSize(),mp3.sampleRate());//allows for the decription of the sound waves
rectMode(CORNERS);
mp3.loop();

//background fader parameters
fade = get(0,0, width,height);// parameter for making the background fade
rWidth = width0.99;
rHeight = height
0.99;
classicVi = new visualizer(); // initializes the class visualizer

if(!started)
{
mp3.pause();
}
}

void draw()
{
if(!started)
{
background(title);
canPauseAndPlay = false;
}
else if(started)
{
canPlay = true;
background(0);
classicVi.drawEQ();
if(canPlay)
{
mp3.play();
pauseAndPlay();
}
}
}
// Start Button Parameters
void mouseClicked()
{
started = true;// tells the program its started playing
}
void keyPressed()
{
if(key == ESC)
{
started = false; //kills the program
mp3.pause();
}
}
// function for pausing and playing the audio
void pauseAndPlay()
{
if(key == ‘p’)
{
mp3.pause();
}
else if(key == ‘q’)
{
mp3.play();
}
}

void close()
{
out.close();
minim.stop();
super.stop();
}

Thanks.
Best,
@bemoregt.

Posts: 3

Participants: 2

Read full topic

Future of ofPoint

$
0
0

@dimitre wrote:

Just wondering if ofPoint will be deprecated in the future, or it is meant to live together with glm.
What do you think of an ofColor(glm::vec3) or ofColor(glm::vec4) initializer?
Cheers

Posts: 1

Participants: 1

Read full topic

ofxOsc communication with CNMAT/OSC

$
0
0

@Aspire94 wrote:

Hi there,

I’m sending OSC messages over UDP(CNMAT/OSC) from and esp32 to my smartphone which runs ofxAndroid and ofxOsc. I seem to be able to receive the messages but not read them I tried to getArgType() and got T for an answer = True. Is there a way to actualy get to the message I send from the esp?

The code on the phone:

while (receiver.hasWaitingMessages()) {
		ofxOscMessage m;
		receiver.getNextMessage(m);

		if (m.getAddress() == "/mac/addresses") {
                      String container = m.getArgAsString(0);
                      if(m.getArgType(0) == OFXOSC_TYPE_TRUE){
                                 //this equals true wich means my message is just true?
                      }
                    //Do some stuff
            }
}

Code thats sends the messages on the esp32:

    for(uint16_t i = 0; i < 64; i++){
      if(maclist[i][0].length() > 11){
        OSCMessage msg(addr);
        msg.add(maclist[i][0]); // maclist[i][0] is a string
        Udp.beginPacket(host, send_port);
        msg.send(Udp);
        Udp.endPacket();
        msg.empty();
        Serial.print("Send OSC -> Value: ");Serial.println(test);
        delay(100);
      }

Posts: 1

Participants: 1

Read full topic

Drawing a line problem

$
0
0

@Apoorva_Singal wrote:

Why does the following code not work. Want to draw a simple line when the mouse is pressed and dragged.

void ofApp::mouseDragged(int x, int y, int button){
button = OF_MOUSE_BUTTON_LEFT;
if (button)
{
ofSetColor(255);
ofDrawLine(x,y, ofGetPreviousMouseX(), ofGetPreviousMouseY());
}

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
button = OF_MOUSE_BUTTON_LEFT;
if (button)
{
ofSetColor(255);
ofDrawLine(x, y, ofGetPreviousMouseX(), ofGetPreviousMouseY());
}
}

Posts: 1

Participants: 1

Read full topic

Building from source

$
0
0

@rtavakko wrote:

Hey guys,

I’ve seen this topic a couple of times on the forum but being new to building projects from source, I’m not sure how to build OF.

I use windows and have built libraries like OpenCV, GLFW, Nana etc. from source using MINGW64 and CMAKE. But these have a CMAKE file in their root which lets you work with CMAKE to build them. I’ve downloaded the msys2 release and successfully (I think…) installed the dependencies with msys2 shell.
When I try using mingw32-make in the “your_oF_directory/libs/openFrameworksCompiled/project” directory I get errors like this:

HOST_OS=MSYS_NT-6.1-7601
FIND: Parameter format not correct
checking pkg-config libraries: cairo zlib openssl glew glfw3 libcurl
with PKG_CONFIG_LIBDIR=
FIND: Parameter format not correct
File not found - *.cpp
FIND: Parameter format not correct
File not found - *.cpp

Any ideas on what inhumanity I’m causing here?

Thanks a lot!

Posts: 1

Participants: 1

Read full topic


Copy texture from one ofFbo to another

$
0
0

@Sam_McElhinney_io wrote:

What’s the simplest, most efficient method for copying a texture from one ofFbo to another? Is it just calling the .copyTo() function?

Posts: 1

Participants: 1

Read full topic

OF Results are something strange when convert to ofImage

$
0
0

@bemoregt wrote:

Hi, All.

I made Co-Saliency map OF version from this code:

But results are something strange when convert cv::Mat to ofImage

original opencv code’s imshow() results are


What’s wrong to me?

my code is here :

#include “ofApp.h”

using namespace cv;
using namespace ofxCv;

// prototype----------------------------------------------------
void PQFT(cv::Mat &pre_img, cv::Mat &next_img, cv::Mat &saliency_map);

//--------------------------------------------------------------
void ofApp::setup(){

aa.load("/Users/mun/Desktop/aa.png");
mm= toCv(aa);
bb.load("/Users/mun/Desktop/bb.png");
nn= toCv(bb);

PQFT(mm, nn, ll);

//cv::imwrite("/Users/mun/Desktop/test.png", ll);
toOf(ll, cc);

}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){

ofSetColor(255);
aa.draw(0,0, 512, 512);
cc.draw(512,0, 512, 512);

}

Thanks.
Best,
@bemoregt.

Posts: 2

Participants: 1

Read full topic

Why ofBeginShape complexity so bad?

$
0
0

@ingyeoking13 wrote:

Hi, I’m beginner.
I wrote some source to draw wave things.
I made it with perlinNoise and vertices… and ofBeginshapes.
but I’m not satisfied with the result.
when I tried to draw a third wave, I got some kind of lagged or bug.
below image shows problem which I’m suffering from.

following source is my source code.

vector<glm::vec2> v, v2, v3;
double fv=777, fv2=132, fv3=0;

void ofApp::setup() {

	ofSetFrameRate(60);
	ofSetWindowTitle("openFrameworks");
	//font.loadFont("BMHANNAPro.ttf", 90);
	//sound.load("Track28.mp3");

	ofBackground(239);
	sound.setSpeed(2.0);
	sound.setMultiPlay(true);
}

void ofApp::update() {
	ofSeedRandom(39);
	v.clear();

	v.push_back({ 0, ofGetHeight() });
	for (int i = 1; i < ofGetWidth()-1; i+=3)
	{
		v.push_back(glm::vec2(i, ofMap(ofNoise(i * 0.001, ofGetFrameNum()*0.00001,fv+=0.000001), 0, 1, 0, ofGetHeight())));
	}
	v.push_back({ ofGetWidth() - 1, ofGetHeight() });

	v2.clear();

	v2.push_back({ 0, ofGetHeight() });
	for (int i = 1; i < ofGetWidth()-1; i+=3)
	{
		v2.push_back(glm::vec2(i, ofMap(ofNoise(i * 0.001, ofGetFrameNum()*0.00001, fv2+=0.000001), 0, 1, 0, ofGetHeight())));
	}
	v2.push_back({ ofGetWidth() - 1, ofGetHeight()});

	v3.push_back({ 0, ofGetHeight() });
	for (int i = 1; i < ofGetWidth()-1; i+=3)
	{
		v3.push_back(glm::vec2(i, ofMap(ofNoise(i * 0.001, ofGetFrameNum()*0.00001, fv3+=0.000001), 0, 1, 0, ofGetHeight())));
	}
	v3.push_back({ ofGetWidth() - 1, ofGetHeight() });


}

//--------------------------------------------------------------
void ofApp::draw() {
	ofSetColor(0, 39, 255, 50);
	ofBeginShape();
	ofVertices(v);
	ofEndShape();

	ofSetColor(233, 233, 39,39);
	ofBeginShape();
	ofVertices(v2);
	ofEndShape();

	ofSetColor(0, 111, 100);
	ofBeginShape();
	//ofVertices(v3); // <--- problems
	ofEndShape();
}

//--------------------------------------------------------------
int main() {
	ofSetupOpenGL(1420, 960, OF_WINDOW);
	ofRunApp(new ofApp());
}

I think the source what I wrote, does not have serious time complexity. :cry:
how can I get more performance?

sorry for lack of English. thanks for reading.

Posts: 1

Participants: 1

Read full topic

Polyline.getvertices() gives output in what form?

Get pixel color from ofVideoPlayer

$
0
0

@Apoorva_Singal wrote:

Hi,

When I need to get pixel data of an image to color i am using this inside a for loop:

ofColor c = image.getColor(x, y);

Is there a similar method to get pixel data from ofVideoPlayer ??

ofColor c = video.getPixel(x,y);

?

Posts: 2

Participants: 2

Read full topic

Install_dependecies not working with 0.10.1 msys2 (windows 10)

$
0
0

@Justin_Savino wrote:

Hello,
I have been able to follow the OF installation guide seemingly successfully up until I have to run the command ./install_dependencies.sh`

which just returns this

>

no errors or anything. Is this normal? I have no experience with msys2 so I have no idea. And when I try to run the make file in …/libs/openFrameworksCompiled/project with mingw32 I get this

HOST_OS=MINGW32_NT-10.0-18362
checking pkg-config libraries:   cairo zlib openssl glew glfw3 libcurl
with PKG_CONFIG_LIBDIR=
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
/bin/sh: /mingw32/bin/pkg-config: No such file or directory
/bin/sh: line 0: return: can only `return' from a function or sourced script
makefileCommon/config.shared.mk:291: *** couldn't find cairo zlib openssl glew glfw3 libcurl 0 pkg-config package or it's dependencies, did you run the latest install_dependencies.sh?.  Stop.

so i figure the install_dependencies.sh did not work for some reason

Posts: 1

Participants: 1

Read full topic

ofxGstreamer setVolume(float) not working

$
0
0

@novas_fronteiras wrote:

hi, everyone!!

i am using ofxGstreamer for every video projects i have and recommend it a lot!
but, i tried some ways to output sound from the video but isnt working.

SET VOLUME
below, this doesnt work:
player.setVolume(1.0);

OFGSTUTILS.APP
below, i changed as arturo posted HERE, but didnt work either:

void ofGstUtils::setVolume(float volume){
//    gdouble gvolume = volume;
//    g_object_set(G_OBJECT(gstPipeline), "volume", gvolume, (void*)NULL);
    
    gdouble gvolume = CLAMP(volume,0,10);
    g_object_set(G_OBJECT(gstPipeline), "volume", gvolume, NULL);
}

and also tried to edit directly the pipeline of the video with no success.

does anyone uses sound + video with ofxGstreamer?
any help will be perfect.

thank you!!

Posts: 1

Participants: 1

Read full topic


I want to draw an image on 3d rectanle plane (as a texture ?)

$
0
0

@bemoregt wrote:

Hi, All.

I want to draw an image on 3d rectanle plane (as a texture ?).

And,

I want to move the plane to the direction of minus z-direction far away.

Like a Apple’s Time Machine.

43

How can I make this code using OF?

Thanks in advance.

Best,
@bemoregt.

Posts: 2

Participants: 2

Read full topic

OfEasyCam zoom into mouse position

Program crashing with std::string

$
0
0

@Antonio_Castles wrote:

Hello Forum,
I am trying to use std::string for a variable. I declare it in my header and everything seems to be fine, but when I give it a value in the setup method in the cpp file the program crashes. I am including < iostreams > and I will try to avoid using namespace std if possible. Any idea why this could be happening? Thanks!

Posts: 2

Participants: 2

Read full topic

Bug/clash between antialiasing and ofShaders

$
0
0

@Sam_McElhinney_io wrote:

So, I think I’ve finally pinned down what was causing a glitcher issue that I raised here in a shader app I’ve been working on.

The shaders run fine on a lot of gpu chips, but on my Mac integrated intel chips the outcome on screen is completely garbled. After a lot of commenting in and out, it turns out the problem is caused whenever the lines ‘ofEnableAntiAliasing()’ or ‘ofDisableAntiAliasing()’ are included. Removing all these calls clears up the glitch.

Don’t know why but it might be a fix that helps someone else out one day.
S

Posts: 1

Participants: 1

Read full topic

Decode PNG from a buffer into ofImage with cv imdecode?

$
0
0

@rychrd wrote:

Hi
I’m having a hard time decoding a PNG image i’ve got stored in a string - i’ve been round the houses several times, but still can’t get anywhere near having pixels : I’m grabbing images from an http server

The data’s base64 encoded, in a Json wrapper if i’ve understood whats going on

auto remoteImg = (ofHttpResponse(ofLoadURL("http://192.168.0.77:7777/data")));
string imgData_b64 = remoteImg.data;    

imgData_b64 = imgData_b64.substr(data.find(",")+1);      // find where the PNG header starts
imgData_b64 = imgData.substr(0, data.size()-2);              // strip off the end quotes and curly brackets

imgDecoded = (ofxIO::Base64Encoding::decode(data)); // works ok

int bufLen = imgDecoded.length();                                                           
char* imgBuf = new char [bufLen+1]; // get a plain array to pass into open cv
strcpy(imgBuf, b64_decoded.c_str());

cv::mat pngMat = cv::imdecode(*imgBuf, CV_8UC4); // decode the PNG string in to a cv::mat

ofxCv::toOf(pngMat, ofImage pngImage);      // convert the mat to an ofImage

From what i can tell, all’s well til the decoding in cv

cv::mat pngMat = cv::imdecode(*imgBuf, CV_8UC4)    // nothing happens

but nothing is ever allocated to the mat -
I;ve also tried

cv::mat pngMat = (cv::imdecode(cv::Mat(1, bufLen, CV_8UC4, *imgBuf), CV_LOAD_IMAGE_ANYDEPTH));

I feel like i’m missing something obvious here - the png is ok -i can paste the data into a website and get the image back out no problems…

Rich

Posts: 1

Participants: 1

Read full topic

Viewing all 4929 articles
Browse latest View live