MasteringOpenCV / code

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

Chapter2_iPhoneAR #75

Open AvinashAmanJha opened 7 years ago

AvinashAmanJha commented 7 years ago

Problem in chapter 2 . No detection is performed by camera

coryl commented 7 years ago

I debugged the issue.

1) Not sure this is a problem, but in SimpleVisualizationController.mm, I was getting cautions so renamed this method: - (void)buildProjectionMatrix:(Matrix33)cameraMatrix screenWidth:(int)screen_width screenHeight:(int)screen_height projectionMatrix:(Matrix44&) projectionMatrix

2) In ViewController.mm, frameSize is not correctly being evaluated and returns (0,0):

self.visualizationController = [[SimpleVisualizationController alloc] initWithGLView:self.glview
                                                                             calibration:camCalib
                                                                               frameSize:frameSize];

To fix this fast: Just change frameSize parameter to CGSizeMake(640,480) (which is the correct video dimensions as the entire project revolves around that resolution preset in VideoSource).

To fix this correctly: Implement a notification to get the correct frameSize when the camera is ready. The problem is in VideoSource.mm getFrameSize returning 0,0 because its not ready. Here is a link to implementing that notification: http://stackoverflow.com/questions/26175409/cmformatdescriptionref-and-cmvideoformatdescriptiongetdimensions