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

I want to run Libtorch(Pytorch C++ Frontend) in OpenFrameworks

$
0
0

@bemoregt wrote:

HI, All.

I want to run Libtorch (Pytorch C++ Frontend) in OpenFraneworks.

LibTorch Site: https://pytorch.org/tutorials/advanced/cpp_frontend.html

If LibTorch is run in OpenFrameworks, It will be very powerful Deep Solution IDE(deep learning + GUI Production for OSX, Win10, & Linux).

The setup() + update() structure of OF is very suitable for trained model’s fast inference.

Like this:
setup() {
// trained deep model loading
// etc init
}
update() {
// fast inference repeatedly of inputed.
}

But I can’t include <torch/torch.h> in XCode.

At CMake method, CMakeLists.txt is like this:

cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(dcgan)

find_package(Torch REQUIRED)

add_executable(dcgan dcgan.cpp)
target_link_libraries(dcgan “${TORCH_LIBRARIES}”)
set_property(TARGET dcgan PROPERTY CXX_STANDARD 11)

and install libtorch for mac: https://download.pytorch.org/libtorch/cpu/libtorch-macos-latest.zip

How can I include libtorch header in XCode ??

Thanks in advance.

Posts: 2

Participants: 1

Read full topic


Quaternion getRotate glm

$
0
0

@pandereto wrote:

In the past i can do

        auto rot = joint.getOrientationQuat();
        ofVec3f axis;
        float angle;
        rot.getRotate(angle, axis);
        ofRotate(angle, axis.x, axis.y, axis.z);

But now with glm i get an error on getRotate, how can i do that code with glm ?¿¿

Posts: 2

Participants: 2

Read full topic

How to change MapTile in ofxMaps

$
0
0

@alzinem wrote:

Hi! Thanks for seeing this topic. I’m an oF newbie.

I’m trying to run the example in ofxMaps Add-on , and It succeeded.
Then, I want to change MapTile in this map next.
I have some URLs of MapTile for example -> * http://www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png and changed “provider.json”, but I couldn’t get tile images in this project. (I think I have to add more change in this add-on.)
Do you know about how to change MapTile in this add-on? Thanks.

Well… Could you help me @bakercp or anyone?

Posts: 3

Participants: 2

Read full topic

Sampling an area from an image

$
0
0

@Regi wrote:

Hi,

I want to do a what seems like a simple task, but I’m getting a bit confused with all the possibilities in OF. Basically I want to sample a 5x5 pixel area from an image to begin with and draw it.

I load up a 100x100 image, get a random (center) position for my 5x5 bucket from that image. The question then becomes, how do I copy/crop that 5x5 pixel data from ofImageto an ofPixels? ofFbo? ofTexture? object. Which one should I use and why? Is it a case-specific decision and can’t be case-agnostic?

Let’s say I just want to draw that random sampled 5x5 pixel area on screen in the end to simplify things.

Posts: 4

Participants: 3

Read full topic

Array and Vectors

$
0
0

@pxt wrote:

Hi!
Im using imGui library and one object takes as an argument an array bool b [] but in order to use in a interactive way i need that array to be fized size according a vector. so i need that bool b [] size be equal to vector size. its possible ?

bool b [] = {false, false}}; // need this fixed size

        for(int i = 0; i <vector.size; i ++){
            if (i % 5 != 0) ImGui::SameLine();
            
            ImGui::PushID(i);
            if(ImGui::Checkbox("##", &b[i])){
            }
            ImGui::PopID();
        }

Posts: 3

Participants: 2

Read full topic

"Recording" a contour obtained with ofxCv

$
0
0

@t.espinoza wrote:

hi all,

i am having trouble understanding how an idea might look as code. i would be grateful for anyone who can offer input and direction :slight_smile:

i am using ofxcv to receive the contour of an object. i want to record it’s movement so that once this specific contour is no longer being tracked, a “shadow” is left behind that is the same shape as the contour and moves exactly how the object did in its lifetime. so if the object moves around in a bunch of irregular spirals and then it disappears, a shadow of the object is drawn and moves in the same irregular spirals, and i can just loop that movement so that once it ends it starts from the beginning again.

some specific questions i have, beyond the general “how i might do what i just described”:

  • ofxcv has a tracker that i think i can use for this? i’m looking at the header file though and am not sure i completely grasp the differences between the labels (current, previous, new, dead).
  • if i am interested in recording multiple objects, and having several shadows and their movements looping and possibly interacting with each other, will it be computationally expensive? are there areas i can optimize?
  • better to use a depth camera over usb camera? i am doing this with controlled lighting with a usb camera right now, but don’t think it will be as uniform in other places.

thank you!

tristan

Posts: 3

Participants: 3

Read full topic

ofBoxPrimitives mode for drawing: centre vs. vertex?

$
0
0

@sgrinschpun wrote:

Hi

I’m trying to have a bunch of ofBoxPrimitives with the same width and depth but different height. The boxes have a parent-child relationship to share transformations and the height is animated differently for every box.
I’m struggling to have all the boxes’ base planes aligned because when I change the height it grows or shrinks symmetrically from the centre of the box.

Is there and ofSetRectMode(OF_RECTMODE_CORNER) setting for ofBoxPrimitives?
How can I change the “anchor” of ofBoxPrimitive?

cheers

Posts: 1

Participants: 1

Read full topic

Quaternion rotate problem

$
0
0

@pandereto wrote:

Hello

Im playing with ofxNI2 and trying to apply the quaternion coming from a skeleton joint to a 3d model, but im not able to make the model rotate, i know that the quaternion contain data as im able to print the angles of that joint.

Maybe im making some dumb mistake in my code

for (int i = 0; i < tracker.getNumUser(); i++)
    {
        ofxNiTE2::User::Ref user = tracker.getUser(i);
        const ofxNiTE2::Joint &joint = user->getJoint(nite::JOINT_HEAD);

        ofPushMatrix();
        ofEnableDepthTest();
        ofTranslate(user->head);

        auto rot = joint.getOrientationQuat();
        float angle = glm::angle(rot);
        glm::vec3 axis = glm::axis(rot);
 
        
        ofRotate(angle, axis.x, axis.y, axis.z);
        
        ofNoFill();
        
        
        model.drawFaces();
        ofDrawBox(0, 0, 0, 200);
        ofDisableDepthTest();
        ofPopMatrix();
}

Also i know that that joint have data because if i do, it works but i do not want to have the translation of that because im drawing over the rgb frame in 2d

        joint.transformGL();
        ofDrawBox(300);
        joint.restoreTransformGL();

Thank you!

Posts: 2

Participants: 2

Read full topic


How can I speed up random circle detection?

$
0
0

@bemoregt wrote:

Hi, All.

I have made Montecarlo Random Circle Detection code.

sarching-1
result

But detection speed is so slow… :sweat_smile:

My code is not optimized for openframeworks, at all.
How can I speed up detection time ?

Thanks in advance.

Best,
@bemoregt.

Posts: 2

Participants: 1

Read full topic

grabScreen crash

$
0
0

@Sam_McElhinney_io wrote:

I’m trying to use the .grabScreen to save the screen view into an image file for export. Using Openframeworks on Visual Studio 17.

I get a crash when the dimensions of the grab are 1675 x 950, which seem pretty small to me - what would be causing this? Is there any way to avoid it?

S

Posts: 1

Participants: 1

Read full topic

Can I issue command line prompts and read the output with the OF app?

$
0
0

@samuset wrote:

I know I can use system() or ofSystem() to issue command line prompts on OSX and Windows, but is there any way to read the output of the command inside the OF app?

For instance, running a command line tool and reading the text it outputs:

$ ./zxing --more 2019_07_01_15_54_42.jpg
  Format: QR_CODE
  Point[0]: 320 6253.25
  Point[1]: 318.5 5814
  Point[2]: 767.5 5795.5
0

Posts: 1

Participants: 1

Read full topic

Getting line number in error message

$
0
0

@edapx wrote:

I am working on an application that has quite a lot of textures. Since a while I am receiving the error:
[ error ] ofTexture: getTextureData(): texture has not been allocated that could happen in a lot of places.

Is there a way to get some information more about where this is happening?

I have tried to use ofSetLogLevel(OF_LOG_VERBOSE) but without any success.

Posts: 1

Participants: 1

Read full topic

I want to get all images filepath name in a directory

$
0
0

@bemoregt wrote:

Hi, All.

I want to get all images filepath name in a directory.
and that diretory is got from draginfo of dragEvent.

My code is here:
void ofApp::dragEvent(ofDragInfo dragInfo){

if( dragInfo.files.size() > 0 ){
    img1.load(dragInfo.files[0]);
    img1.setImageType(OF_IMAGE_COLOR);
    
    ofDirectory dir(dragInfo.files[0]);
    dir.allowExt("png");
    dir.listDir();
    // all file
    for(int i = 0; i < dir.size(); i++){
        ofLog() << dir.getPath(i) << endl;
    }
}
ofSetWindowShape(img1.getWidth(), img1.getHeight());

}

But I met this error:
“[ error ] ofDirectory: listDir:() source directory does not exist:”

What’s wrong to me ?

Thanks.

Posts: 1

Participants: 1

Read full topic

How can i rotate a ofTrueTypeFont?

$
0
0

@lkkd wrote:

I’m trying to rotate a truetypefont (string). I’m using ofRotate but the string just disappear here is the code. I’m using OF iOS.

ofPushMatrix();
ofRotateZ(45);
ofSetColor(255,0,0);
redblue.drawString(“100”, 400 * scale, 162 * scale);

Posts: 2

Participants: 2

Read full topic

How to get ofFbo data without drawing to screen

$
0
0

@khho wrote:

I want to blur an image using shader, and then save the resulting image. I started from an example of openframework v0.10.1, that is, shader/09_gaussianBlurFilter. I added an ofPixels (called inputPixels) and ofImage (called outputImage) to achieve my objective. Below are my codes, where I added comments for what I added by “added by me.”

The program works. It can save an image file, same as the screen shows. However, I don’t want to draw anything to screen. I wanted to blur an image and save the result in a more clean way. So I tried to remove “fboBlurOnePass.draw(0, 0);” and “fboBlurTwoPass.draw(0, 0);.” However, the program failed to save a meaningful image file if I remove the two.

I was wondering if someone can tell me how to modify the codes, so as to blur an image without drawing anything to screen. Thank you very much.

void ofApp::draw(){
    float blur = ofMap(mouseX, 0, ofGetWidth(), 0, 4, true);
    
    //----------------------------------------------------------
    fboBlurOnePass.begin();
    
    shaderBlurX.begin();
    shaderBlurX.setUniform1f("blurAmnt", blur);

    image.draw(0, 0);
    shaderBlurX.end();
    fboBlurOnePass.end();
    
    //----------------------------------------------------------
    fboBlurTwoPass.begin();
    
    shaderBlurY.begin();
    shaderBlurY.setUniform1f("blurAmnt", blur);
    
    fboBlurOnePass.draw(0, 0);
    fboBlurOnePass.readToPixels(inputPixels); // added by me
    shaderBlurY.end();
    fboBlurTwoPass.end();
    
    //----------------------------------------------------------
    ofSetColor(ofColor::white);
    fboBlurTwoPass.draw(0, 0);
    fboBlurTwoPass.readToPixels(inputPixels); // added by me

    outputImage.setFromPixels(inputPixels); // added by me
    outputImage.saveImage("screenshot.png"); // added by me
}

Posts: 1

Participants: 1

Read full topic


Link to OF documentation page based on function name?

$
0
0

@cuinjune wrote:

Whenever I want to learn about any OF function or class, I google the name and usually they appear as the first search result.

I wonder if it is possible to get the direct link to the documentation page of the function/class based on its name without having to search through Google.

I tried the search feature in https://openframeworks.cc/documentation/ but it seems to only work for classes.

Posts: 1

Participants: 1

Read full topic

How can I make kenburns effect from rect1 to rect2?

$
0
0

@bemoregt wrote:

Hi All.

I made kenburns effect like animated image magnification.

At now, I am using ofScale and x0, y0.
But, I want to convert from rect1 to rect2.

How can I make kenburns effect from rect1 to rect2?

My Code:
//--------------------------------------------------------------
void ofApp::setup(){
img1.load("/Users/mun/Desktop/lena512.png");

rect1= ofRectangle(0, 0, 1024, 768);
rect2= ofRectangle(100, 100, 102, 77);

t=1;
xx= 1;
yy= 1;

}

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

ofSleepMillis(30);
img1.update();
ss= 1 + t * 0.01;

t += 1;
if(t > 500) t = 0;

}

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

ofBackground(75);

ofSetColor(255, 255, 255);
//ofScale(4.0f, 4.0f, 1.0f);
ofScale(ss);
img1.draw(xx-t*0.5, yy-t*0.5);   

}

Thanks.

Posts: 1

Participants: 1

Read full topic

MSYS2ROOT path issue

$
0
0

@zack1 wrote:

can someone help me with this issue : https://github.com/openframeworks/openFrameworks/issues/6333

or can some one guide me through set path directly in openframeworks QT plugin , as i set paths multiple times but no success always getting same error

> warning: error : your PATH is incorrect. Please make sure that {MSYS2ROOT}\mingw32\bin;{MSYS2ROOT}\usr\bin is at the beginning of your PATH
warning: Product 'app2' had errors and was disabled.
warning: Error while handling product 'openFrameworks':
 warning: Product 'openFrameworks' had errors and was disabled.

Posts: 4

Participants: 2

Read full topic

I made Xcode version that using libtorch

Is it possible to force OF app window to maintain focus?

$
0
0

@samuset wrote:

I am making an OF app for Windows 10 and I have a problem with another app, working with the OF app, opening a window every so often and stealing focus from the fullscreen OF app.

Is there any way to prevent this either by disabling focus stealing or forcing the OF app to maintain focus?

Posts: 2

Participants: 2

Read full topic

Viewing all 4929 articles
Browse latest View live


Latest Images