I am new to openFrameworks and I am trying to get the ofxTimeline addon to compile with openFrameworks 9 using Xcode on OSX Sierra.
The build of ofxTLImageSequence.cpp is failing in ofxTLImageSequence::recomputePreview() method.
This is not the actual code, but psuedo code of what is causing the error: ofTexture->loadData( ofImage.getPixels(), …)
It seems that ofImage.getPixels() is not returning what ofTexture.loadData() requires and is causing the build error below.
Does any one have any ideas how to fix this?
Thanks,
Chris
The build errors:
Projects/openframeworks9/addons/ofxTimeline/src/ofxTLImageSequence.cpp:236:14: No matching member function for call to 'loadData'
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:474:7: Candidate function not viable: no known conversion from 'ofPixels_<unsigned char>' to 'const unsigned char *const' for 1st argument
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:482:7: Candidate function not viable: no known conversion from 'ofPixels_<unsigned char>' to 'const unsigned short *' for 1st argument
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:490:7: Candidate function not viable: no known conversion from 'ofPixels_<unsigned char>' to 'const float *' for 1st argument
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:549:7: Candidate function not viable: requires 3 arguments, but 4 were provided
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:955:10: Candidate function not viable: requires 5 arguments, but 4 were provided
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:520:7: Candidate function not viable: requires 2 arguments, but 4 were provided
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:527:7: Candidate function not viable: requires 2 arguments, but 4 were provided
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:534:7: Candidate function not viable: requires 2 arguments, but 4 were provided
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:494:7: Candidate function not viable: requires single argument 'pix', but 4 arguments were provided
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:502:7: Candidate function not viable: requires single argument 'pix', but 4 arguments were provided
Projects/openframeworks9/libs/openFrameworks/gl/ofTexture.h:510:7: Candidate function not viable: requires single argument 'pix', but 4 arguments were provided
The ofxTLImageSequence::recomputePreview() method:
void ofxTLImageSequence::recomputePreview(){
if(!loaded){
ofLogError("ofxTLImageSequence -- hasn't been loaded");
return;
}
if(bounds.height < 20){
ofLogError("ofxTLImageSequence -- too squished at height " + ofToString(20));
return;
}
float widthPerFrame = bounds.height/imageHeight * imageWidth;
int framesToShow = (bounds.width / widthPerFrame) + 1;
if(framesToShow == 0){
ofLogError("ofxTLImageSequence -- no frames to show!");
return;
}
int startIndex = getIndexAtPercent(zoomBounds.min);
int endIndex = getIndexAtPercent(zoomBounds.max);
int framesInRange = (endIndex - startIndex);
int frameStep = framesInRange / framesToShow;
int fameIndex = 0;
clearPreviewTextures();
for(int i = 0; i < framesToShow; i++){
ofImage* thumbnail = frames[startIndex+frameStep*i]->getThumbnail();
PreviewTexture p;
p.frameIndex = startIndex+frameStep*i;
p.texture = new ofTexture();
p.texture->allocate(thumbnail->getWidth(), thumbnail->getHeight(), ofGetGlInternalFormat(thumbnail->getPixelsRef()));
// *** BUILD IS FAILING HERE *** //
p.texture->loadData(thumbnail->getPixels(), thumbnail->getWidth(), thumbnail->getHeight(), ofGetGlInternalFormat(thumbnail->getPixelsRef()));
p.bounds = ofRectangle(widthPerFrame*i, 0, widthPerFrame, bounds.height);
previewTextures.push_back( p );
}
}
Thanks for the reply @hamoid. I will look into that.
I did more research last night and I think my issue is related to an openFrameworks ofImage update I found on github (see the link below).
I wonder if @arturo might be able to confirm that? It looks like a method was removed that used to return an unsigned char* and now, getPixels returns a raw pointer to pixel data.
I have not seen other posts about the problem I’m having, and I wonder if others have experienced the same build issue?
I used to develop full-time in C++. I now code in Ruby on Rails. It’s been years since I’ve done a deep-dive into C++ pointer issues. So I am trying to get up to speed again. I would appreciate any advice how to resolve this. Do I have to cast the pointer returned by getPixels()?
Hi,
you can just use ofTexture->loadData( ofImage.getPixels()) as ofImage.getPixels() returns an ofPixels object reference, out of which of texture is able to figure out the rest of the parameters needed to upload the texture.
No need to cast anything.
cheers
I think that’s what the ofxTimeline code is doing in the ofxTLImageSequence::recomputePreview() method.
Here’s the line of code on GitHub that won’t build. The way I am understanding this is …
First it creates a “thumbnail” object (which is a pointer to an ofImage) as follows … ofImage* thumbnail = frames[startIndex+frameStep*i]->getThumbnail();
Then, it callsloadData() using getPixels() as the first parameter: PreviewTexture p; ... p.texture = new ofTexture(); ... p.texture->loadData(thumbnail->getPixels(), thumbnail->getWidth(), thumbnail->getHeight(), ofGetGlInternalFormat(thumbnail->getPixelsRef()));
PreviewTexture is a struct defined as follows… typedef struct { ofTexture* texture; ofRectangle bounds; int frameIndex; } PreviewTexture;
It appears it’s not finding a method signature that matches the parameters being passed in. Namely the pointer to the pixel data returned by the getPixels() method.
Hi, I see. I kinda gave up with ofxTimeline a while ago, so I ended up with a heavily modified version, although I haven’t updated it to 0.9.x.
I’ll give it a try now and I’ll let you know.
best
hey so I was able to get it to work using this fork https://github.com/leozimmerman/ofxTimeline
It needs ofxAudioDecoder https://github.com/kylemcdonald/ofxAudioDecoder
so, I had to remove the ofxAudioDecoder folder in the project navigator and the add it back using the xcode OF plugin menu (if you haven’t installed it you should).
last thing was to change the line you mention above just leaving p.texture->loadData(thumbnail->getPixels();
Sorry for being lazy and not making a new branch, commit,…
hope it helps.
best
Hi @roymacdonald, I was able to get a successful build this morning.
There was a problem building the ofxAudioDecoder. But it was a simple change, updating the AudioDecoderCoreAudio header file. I had to change #ifdef TARGET_OS_IPHONE to #ifdef TARGET_OF_IOS.
As for the OFXcodeMenu plugin … the project builds successfully and I updated the UUID for Xcode Version 8.3, but it still does not display in Xcode. I’ll figure that out eventually. In the meantime the project generator worked for updating the ofxAudioDecoder addon in the ofxTimline project.
Why am I doing all of this? I want to learn about coding video projection mapping apps and learn more about openFrameworks development on OS X. I downloaded the LPMT project and my personal challenge is to get LPMT running on openFrameworks 0.9x and OS X Sierra. So, I will probably be forking more addons to get this to work. ofxTimeline was where I started.
I’m sure I’ll be posting more as I go through this learning process.