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

Multiple receivers with spout and windows

$
0
0

@sam_hains wrote:

Hey OFX forum,

Is there a simple way with openframeworks, spout and windows to work with multiple receivers?

I would like to be able to define a receiver that will only receive textures that have been sent to a specific name.

looks like ofxSpout’s receiver function is completely broken and ofxSpout2 will only let you select receivers via a selectReceiverPanel (not programmatic)…

I’m imagining something like this in the setup function:

receiver.setup("A"); // only receives textures sent to 'A'
receiver2.setup("B"); // only receives textures to 'B'

Thanks :slight_smile:

Sam

Posts: 1

Participants: 1

Read full topic


How to delete own 3dboxprimitive object

$
0
0

@thomasjhof wrote:

Hi, I’m trying to let the user create and delete my own box object that inherits 3dboxprimitive. I’m trying to use the delete keyword on a pointer that points to the box that the user wants to delete. I don’t think the block is being deleted correctly because when I try I get an error and the application crashes. How should I go about getting deleting the box.

Posts: 1

Participants: 1

Read full topic

Shader setupShaderFromSource not working

$
0
0

@Jhovarie_Guiang wrote:

Hello friends I need help here.

First my shader works if I load it from file

shader.load( "shaderVert.c", "shaderFrag.c" ); //load from file

I am trying to load it from string because I dont want to load it from file.

I tried this but it doest not work.

shader.setupShaderFromSource(GL_VERTEX_SHADER, R"(
#version 120
#extension GL_ARB_texture_rectangle : enable
#extension GL_EXT_gpu_shader4 : enable

void main() {
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_FrontColor = gl_Color;
}

)");
shader.setupShaderFromSource(GL_FRAGMENT_SHADER, R"(
#version 120
#extension GL_ARB_texture_rectangle : enable
#extension GL_EXT_gpu_shader4 : enable
uniform sampler2DRect texture0;

void main(){
	vec2 pos = gl_TexCoord[0].xy;
	vec4 color = texture2DRect(texture0, pos);
	color.r = 1.0 - color.r;
	gl_FragColor = color;
}
)");

whats wrong with my code? I need to load it from string I dont want load from file.

Posts: 2

Participants: 2

Read full topic

ofxJSONRPC how to lock variables set in jsonrpc methods from the main thread?

$
0
0

@Nil0 wrote:

I have an application that crashes, allthough rarely. ofxJSONRPC metod sets a boolean flag while update() reads it, that I guess cause access violations. With ofThread I can lock my way out of similar, but what would I do in this case? I need to lock ofxJSONRPC thread, when either itself or main thread access variables. Is there a simple trick or a suggestion to architect my way out of it?

Posts: 1

Participants: 1

Read full topic

You are in room 1

$
0
0

@opseidon wrote:

Hello OF.

How would I plug & play and RPG that could start with something like:

  • Your ai in room 1;

Thanks

Posts: 5

Participants: 2

Read full topic

How to normalize texture coordinates of ofMesh?

$
0
0

@sam_hains wrote:

Running into some issues when attempting to draw an ofMesh in an FBO that has been initialized to use 2D texture coordinates…

In the documentation for ofMesh::addTexCoord it says:

Add a Vec2f representing the texture coordinate. Because OF uses ARB textures these are in pixels rather than 0-1 normalized coordinates.

So my question is, quite simply, is there a way to use 0-1 normalized coordinates with ofMesh? Or alternatively, is there a way to convert ofMesh’s texture coordinates to use a 0-1 normalized coordinate?

Thanks!

Sam

Posts: 3

Participants: 2

Read full topic

Initialize variables in setup() for use in draw()

$
0
0

@CCx266 wrote:

Hello,
This is a very basic question but if I would be glad to receive some help on understanding this.
My ofApp.cpp is like this:

void ofApp::setup(){
	tcpComObject.setup();
}
// and so on for all of update, draw, etc...

So, in my seperate cpp files corresponding to the class:

//tcpCom.cpp (only parts of interest)
void tcpCom::setup(){
	std::vector<std::string> cmdVector(8, "a");
	ofLog() << "cmdVector size: "<< cmdVector.size();
	ofLog() << "cmdVector capacity: "<< cmdVector.capacity()<< endl;
}
void tcpCom::draw(){
	ofDrawBitmapString( "cmdVector size: " + ofToString(cmdVector.size()) + " cap: " + ofToString(cmdVector.capacity()), 15, 30);

When I run the release, I have this output on the console:
[notice ] cmdVector size: 8
[notice ] cmdVector capacity: 8

But what is drawn is :
cmdVector size: 0 cap: 0

That’s where I’m lost, so here are my two questions:
Are those variables different when they are in different functions ? I know they can be global or local, but I thought the setup function was there to initialize variables. Is there a need to initialize variables, where ?

Thanks. Tell me if this should go to StackOverflow.com preferably, but I like it in here.

Posts: 6

Participants: 2

Read full topic

Ofx Gui Extended

$
0
0

@niranjanbhuta wrote:

When I add buttons (ofParameter) to ofxConatainer, it is well printed on screen but the distance between to consecutive buttons (padding) can not be zero. How to eliminate gap between buttons? Can this be done by other addons if not possible by this?

Posts: 1

Participants: 1

Read full topic


DVB-usb reciever

$
0
0

@drPickles wrote:

Apologies if this is a simple question but…
I have recently picked up a dvb-t receiver from a charity shop. It’s a Hauppauge WinTv Nova-T. It’s working great with VLC/Kaffiene, and is currently located in:

/dev/dvb/adapter0

and not in:
/dev/v4l/

I’m running LinuxMint and was wondering if there was a way of grabbing the pixels from it?

So far I have tried streaming the broadcast through VLC over UDP. But being quite the beginner I have tried and searched for methods for 2 days with no luck.

I’m aware that it might be possible to grab the ‘MPEG2’ from the stick using ofGstVideo grabber? I’ve been playing around with ofGstDevice but with no luck.

If anyone could point me in the right direction I’d be greatly appreciative!

Thanks in advance!

Posts: 1

Participants: 1

Read full topic

Setup qt windows make bash: make: command not found

$
0
0

@Jhovarie_Guiang wrote:

Hello I am fallowing this setup instruction from here http://openframeworks.cc/setup/msys2/

Now I cannot fallow this step.

Open an MINGW32 shell (run C:\msys64\mingw32_shell.bat) and compile oF libraries:

cd your_oF_directory/libs/openFrameworksCompiled/project
make

In my terminal I get something like this.

$ make
bash: make: command not found

I am trying to setup openframework for qt on windows os… any help?

Posts: 1

Participants: 1

Read full topic

Saving data each second

$
0
0

@HarryLee186 wrote:

Hi,

I have the following code inside my draw method

record.loadFile("recording.xml");
	record.addValue("record:beatsPerMinute", heartRate);
	record.addValue("record:time", ofGetTimestampString());
	record.saveFile("recording.xml");

I want it to to save this information only once every second. Could anyone tell me how to do this?

Posts: 1

Participants: 1

Read full topic

How about recording my voice through my computer microphone in OF

$
0
0

@JingSHE wrote:

How about recording my voice in real time through my computer microphone?
And display the wave of my voice??

Looking forward your help!

Thanks a lot!

Posts: 2

Participants: 2

Read full topic

Which glm version is 0.10 using?

$
0
0

@edapx wrote:

Hello, I have some issue with glm::intersectRaySphere, I have seen here https://github.com/g-truc/glm/issues/8 that there was a bug in an old glm version, and I am trying to figure out if this old bug affects also the glm version used by openFrameworks, but unfortunately I can not find out which version of glm is OF using.

Posts: 5

Participants: 3

Read full topic

High Resolution Capable show up really small in mac

WebCam Video Frame rate not set by VideoGrabber

$
0
0

@nitinkatyal1314 wrote:

Hi,

I am new to open frameworks. Based on the suggestions from the forums, I choose OfxVideorecorder to record data from built camera of my Mac to an mp4 file. I have also added “GUI” buttons to start / stop my recording. Apparently, even after using setDesiredFrameRate of the ofVideoGrabber, I see lag in my webcam.

Here is my myApp.h file:

#pragma once

#include "ofMain.h"
#include "ofxVideoRecorder.h"
#include "ofxGui.h"
#include "PlayVideos.h"

class ofApp : public ofBaseApp{

	public:
		void setup();
		void update();
		void draw();

		void keyPressed(int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased(int x, int y, int button);
		void mouseEntered(int x, int y);
		void mouseExited(int x, int y);
		void windowResized(int w, int h);
		void dragEvent(ofDragInfo dragInfo);
		void gotMessage(ofMessage msg);
    
    ofVideoGrabber webcam;
    ofxVideoRecorder recorder;
    ofxPanel gui;
    ofxButton startRecording;
    ofxButton stopRecording;
    ofxButton playRecordedVideos;
    
    void record();
    void finishRecording();
    void play();
    
    bool videoSetupComplete;

    int index;
    PlayVideos playObj;
    
		
};

Here is my myApp.cpp file:

#include <sstream>
#include <string>
#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
    
    index = 0;
    videoSetupComplete = false;
    
    startRecording.addListener(this, &ofApp::record);
    stopRecording.addListener(this, &ofApp::finishRecording);
    playRecordedVideos.addListener(this, &ofApp::play);
    
    
    // setup the gui
    gui.setup();
    gui.add(startRecording.setup("Start Recording"));
    gui.add(stopRecording.setup("Stop Recording"));
    gui.add(playRecordedVideos.setup("Play Recordings"));
    
    //set the app framerate to 60
    ofSetFrameRate(60);
    
    ofSetLogLevel(OF_LOG_VERBOSE);
    
    // set the webcame framerate to 30
    webcam.listDevices();
    webcam.setDeviceID(0);
    webcam.setDesiredFrameRate(30);
    webcam.setup(1280, 720);
    
}

void ofApp::record(){

    videoSetupComplete = false;
    
    ostringstream str1;
    str1 << index;
    
    std::string filename = str1.str() + ".mp4";
    
    std::cout<< "Starting to record ";
    
    // record at 30 fps
    recorder.setup(filename, webcam.getWidth(), webcam.getHeight(), 30);
    
    // start the recorder
    recorder.start();
    
}

void ofApp::finishRecording(){
    
    std::cout<< "Finished Recording ";
    
    index = index + 1;
    recorder.close();
    
}

void ofApp::play() {
    
    //close the webcam
    webcam.close();
    
    playObj.setup();
    //playObj.draw();
    
    videoSetupComplete = true;
}

//--------------------------------------------------------------
void ofApp::update(){
    
    webcam.update();
    
    // add frame to the recorder
    if(webcam.isFrameNew()){
        bool success = recorder.addFrame(webcam.getPixels());
        if (!success) {
            ofLogWarning("This frame was not added!");
        }
    }
    
    // Check if the video recorder encountered any error while writing video frame or audio smaples.
    if (recorder.hasVideoError()) {
        ofLogWarning("The video recorder failed to write some frames!");
    }
    
    if (videoSetupComplete) {
        playObj.update();
    }
    
    
}

//--------------------------------------------------------------
void ofApp::draw(){
    gui.draw();
    webcam.draw(100, 100);
    
    if (videoSetupComplete) {
        playObj.draw();
    }
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){
    
}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
    
}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
    
}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
    
}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
    
}

//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
    
}

//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
    
}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
    
}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
    
}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
    
}


Below is the console response of my app:

Starting to record [verbose] execThread: starting command: bash --login -c 'ffmpeg -y -an -r 30 -s 1280x720 -f rawvideo -pix_fmt rgb24 -i "/Users/nitkatya/Kepler/of_v0.9.8_osx_release/apps/myApps/camRecorder/bin/data/ofxvrpipe0" -r 30  -vcodec mpeg4 -b 2000k -acodec pcm_s16le -ab 128k "/Users/nitkatya/Kepler/of_v0.9.8_osx_release/apps/myApps/camRecorder/bin/data/0.mp4"' &
[verbose] execThread: command completed successfully.
[verbose] Recordi[nvge.r
b
ose] ofxVideoDataWriterThread: opening pipe: /Users/nitkatya/Kepler/of_v0.9.8_osx_release/apps/myApps/camRecorder/bin/data/ofxvrpipe0
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
[warning] ofxVideoDataWriterThread: got file descriptor 11
Input #0, rawvideo, from '/Users/nitkatya/Kepler/of_v0.9.8_osx_release/apps/myApps/camRecorder/bin/data/ofxvrpipe0':
  Duration: N/A, start: 0.000000, bitrate: 663552 kb/s
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1280x720, 663552 kb/s, 30 tbr, 30 tbn, 30 tbc
Please use -b:a or -b:v, -b is ambiguous
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Output #0, mp4, to '/Users/nitkatya/Kepler/of_v0.9.8_osx_release/apps/myApps/camRecorder/bin/data/0.mp4':
  Metadata:
    encoder         : Lavf58.12.100
    Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 1280x720, q=2-31, 2000 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.18.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 0 vbv_delay: -1
frame=    4 fps=0.0 q=2.0 size=     256kB time=00:00:00.10 bitrate=20961.4kbits/s speed=0.175x    
frame=    6 fps=5.3 q=5.1 size=     256kB time=00:00:00.16 bitrate=12580.1kbits/s speed=0.147x    
frame=    8 fps=4.7 q=10.5 size=     256kB time=00:00:00.23 bitrate=8986.8kbits/s speed=0.136x    
frame=   10 fps=4.4 q=16.3 size=     256kB time=00:00:00.30 bitrate=6990.2kbits/s speed=0.132x    
frame=   12 fps=4.2 q=17.0 size=     256kB time=00:00:00.36 bitrate=5719.4kbits/s speed=0.129x    
frame=   14 fps=4.1 q=17.5 size=     256kB time=00:00:00.43 bitrate=4839.7kbits/s speed=0.127x    
frame=   16 fps=4.1 q=18.9 size=     256kB time=00:00:00.50 bitrate=4194.5kbits/s speed=0.127x    
frame=   18 fps=4.1 q=23.8 size=     256kB time=00:00:00.56 bitrate=3701.1kbits/s speed=0.128x    
frame=   20 fps=4.0 q=26.0 size=     256kB time=00:00:00.63 bitrate=3311.5kbits/s speed=0.128x    
frame=   22 fps=4.0 q=25.6 size=     256kB time=00:00:00.70 bitrate=2996.2kbits/s speed=0.128x    
Finished Recording [verbose] ofxVideoDataWriterThread: closing pipe: /Users/nitkatya/Kepler/of_v0.9.8_osx_release/apps/myApps/camRecorder/bin/data/ofxvrpipe0
frame=   23 fps=3.8 q=24.6 size=     256kB time=00:00:00.73 bitrate=2860.0kbits/s speed=0.122x    
frame=   23 fps=3.7 q=24.6 Lsize=     476kB time=00:00:00.73 bitrate=5319.5kbits/s speed=0.117x    
video:475kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.196626%

It seems like my frame rate is very low. How do I fix this?

Posts: 1

Participants: 1

Read full topic


OSX: Shader examples not rendering

$
0
0

@cassm wrote:

Hi,

I am new to OpenGL, and currently trying to work through the shader examples (actually I’m in the middle of a project which I am surprised to discover needs me to use shaders for alpha masking, but that’s a whole other story). I am running across an issue where none of the shaders from the examples are showing. For example, in shader/01_simpleColourQuad I get a blank grey window, and in gl/geometryShaderExample I only get the white lines on a black background, regardless of whether the shader is currently active. I am using OSX high sierra and openframeworks 0.9.8. I have tried building the examples both in xcode and in clion, and the only build warning I get is as follows:

ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks//QuickTime.framework/QuickTime.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks//QuickTime.framework/QuickTime.tbd

Any advice or suggestions would be greatly appreciated.

-Cass

Posts: 3

Participants: 2

Read full topic

STRINGIFY error: invalid preprocessing directive

ofSaveScreen Transparent PNG?

$
0
0

@ayruos wrote:

I’m pretty sure this is a very trivial problem, I’m trying to save an image of my app with ofSaveScreen as a PNG file, I have no background that I’m drawing and I wanted to save this PNG with a transparent background. I’m not using any FBOs or anything - what’s the easiest way to save a transparent PNG?

Attached is what’s exporting - the grey background is what I don’t want.

Posts: 3

Participants: 2

Read full topic

Box2D - multiple shapes to a body

$
0
0

@benek wrote:

Hello there,
I would like to create a complex shape in Box2D with multiple fixtures.
Zeichenfl%C3%A4che%201

In the best case the shape would look like the one on the left and it would rotate around the center.
I already created a shape that looks exactly like this connected with joints, but as I know joints are not able to become completly rigid. So each shape moves individually which i dosen’t want.

My second attempt was to create a complex polygon like the one on the right, but wasn’t able to use the polygonshape either. For now I try to explore the polygonshape more so that i might come to an answer.

Do you guys have any other ideas how I can create shapes like this?

Greetings
Bene

Posts: 2

Participants: 2

Read full topic

How do i get the average red, green and blue from an ofVideoPlayer?

$
0
0

@howdy wrote:

Im using this:

ofPixels & pixels = movie.getPixels();
    
    int vidWidth = pixels.getWidth();
    int vidHeight = pixels.getHeight();
    int nChannels = pixels.getNumChannels();
    int allRed = 0;
    int allGreen = 0;
    int allBlue = 0;
    
    for(int i = 0; i<vidWidth; i++){
        for(int j = 0; j<vidHeight; j++){
            allRed = allRed + pixels[(j*vidWidth+i)*nChannels];
            allGreen = allGreen + pixels[(j*vidWidth+i)*nChannels+1];
            allBlue = allBlue + pixels[(j*vidWidth+i)*nChannels+2];
    }
    }
    int avgRed = allRed/(vidHeight*vidWidth);
    int avgGreen = allGreen/(vidHeight*vidWidth);
    int avgBlue = allBlue/(vidHeight*vidWidth);

Still not getting the expected values

Posts: 2

Participants: 2

Read full topic

Viewing all 4929 articles
Browse latest View live