Tuesday 15 January 2013

xcode - Convert from 1280x720 to UIView dimensions -


I think the AVCaptureDevice app from the sample buffer representative marks the QR finder's app. Now I am trying to put the box on the screen to cover QR numbers. However, I'm having trouble converting between 1280x720 pixel resolution and cameraView size

. I have a method that converts a CGRect on the basis of these standards (and the fact that I'm trying to write the visual coordinate system is inverted-down), but it will not work in anything with the orientation of the camera device. Could. Here is my code for the converted method:

  - (CGRect) convertRect: (CGRect) oldRect From90DegreeRotatedCameraSize1280x720ToUIViewSize: (CGSize) viewSize {// Remember that we are using the size aspect of gravity Double filling xscale = visual system With / 720; Double yScale = viewSize.height / 1280; If (X of the X scale & lt; yScale) CGRectMake (oldRect.origin.x * X scale, viewSize.height - oldRect.origin.y * X scale, oldRect.size.height * X scale, oldRect.size.width * X Scale) return; Any other return CGRectMake (oldRect.origin.x * yScale, viewSize.height - oldRect.origin.y * yScale, oldRect.size.height * yScale, oldRect.size.width * yScale); }   

Has anyone found a beautiful to solve this relatively simple special coordination problem?

Edit -

I have an NSLog orientation of the connection video and it has come to know that it never changes from 1 (which I think is based on this picture orientation It should be easy to find solutions, because coordinates do not change in different tilt.

Any ideas, cite the community?

explained this:

IOS fills a view, it focuses on it So that both sides are cut off. To transition between the visual coordinates, you have to scale and then translate into the direction that was cut:

  Return CGRectMake (oldRect.origin.x * xScale, oldRect.origin. Y * X scale - (1280 * X scale - viewSize.height) / 2, oldRect.size.height * X scale, oldRect.size.width * yScale);    

No comments:

Post a Comment