MasteringOpenCV / code

Code for the book "Mastering OpenCV with Practical Computer Vision Projects" by Packt Publishing 2012.
Other
2.73k stars 1.65k forks source link

Chapter 2, marker-AR not rendering #50

Closed mirceamironenco closed 9 years ago

mirceamironenco commented 9 years ago

Hello,

I'm having a bit of trouble running the second chapter, respectively I've printed the marker, but it's not rendering anything on top of it. Moreover, the framebuffer seems to be deallocating when I start the application.

Any idea what might be wrong?

Tested on iOS 8.3, iPhone 5S.

BloodAxe commented 9 years ago

Hi! I suspect it caused by changes in iOS API. This example has been written for iOS 6.x and lately adopted to iOS 7. A support for iOS 8 has not been considered.

Example project for CH2 uses OpenGL ES 1.0. Nowadays it's very outdated and OpenGL ES 2.0 is minimal recommended version for new apps. I believe it is possible to update this code to support iOS 8. However this will move code too far from chapter's version which can cause problems with understanding it. Therefore I encourage you to use source code as reference and write rendering code using OpenCV ES 2 API.

mirceamironenco commented 9 years ago

I will try to adapt the code to iOS 8 and then make a pull request, you could contain it as a separate version. However, being new to computer vision I could use a few pointers.

cfr commented 9 years ago

Feel free to contact me with iOS-related questions.

P.S. use smart pointers

BloodAxe commented 9 years ago

Feel free to make PR, I will include it into separate branch.

As a quick start I suggest you to start with OpenGL Camera Ripple example from Apple. It has video capture and OpenGL ES 2.0 render pipeline. You just have to pass image buffer to C++ code and update position matrix for 3D object.

mirceamironenco commented 9 years ago

Hi,

In OpenGL ES 2.0 there is no matrix mode, I'm having trouble actually drawing anything. A little help? Or would you rather I use the processing pipeline for OpenGL 2.0 and draw using the old code (ES 1.0)?

BillBai commented 9 years ago

Hey guys~ I think I found where the bug is. It is NOT about the openGL. In iOS 8, -(void)buildProjectionMatrix:screenWidth:screenHeight:matrix:] in SimpleVisualizationController returns a wrong projection matrix.

BloodAxe commented 9 years ago

@BillBai can you please clarify what 'wrong' means in this context?

BillBai commented 9 years ago

@BloodAxe Well, just found the actually problem is in the -(CGSize)getFrameSize method in VideoSource.mm. It returns (0, 0) in iOS 8. And this makes the projection matrix {-inf, 0, 0, ......}.

I think this may help: http://stackoverflow.com/questions/25902122/ios8-video-dimension-cmvideodimensions-returns-0-0

totutete commented 9 years ago

@BillBai I run this program on ipad mini2 referring to your tips,but the three-dimensional coordinates is't on the mark ,do you get the correct result use ios8. ?

yycuc commented 8 years ago

Same problem