Re: Rotating a QTCaptureView
Re: Rotating a QTCaptureView
- Subject: Re: Rotating a QTCaptureView
- From: Nicko van Someren <email@hidden>
- Date: Sat, 9 Feb 2008 08:20:44 +0000
On 9 Feb 2008, at 00:29, Randall Meadows wrote:
On Feb 8, 2008, at 2:32 PM, Randall Meadows wrote:
I'm using a QtCaptureView to preview a video input source. I need
to rotate the displayed video by 90°.
[snip]
What am I missing here?
Answering my own question, for posterity:
Implement the delegate method:
- (CIImage *)view:(QTCaptureView *)view willDisplayImage:(CIImage
*)image
{
return [image
imageByApplyingTransform:CGAffineTransformMakeRotation(90.0 * M_PI /
180.0)];
}
You might want to take a look at the CGAffineTransform created above
to see if the 'a' and 'd' values in the transform are both zero or if
there is any rounding error. When you make a rotation transform like
this, four of the transform values are filed in with the sine and
cosine of the angle (which in this case is the irrational number pi/2)
so the values might not come out exact. While the errors are likely
to have a negligible impact visually, having exact 0.0 in 'a' and
'd' (and exact 1.0 and -1.0 in 'b' and 'c') will allow the graphics
subsystem to perform substantial optimisation in the rendering, which
will be helpful if you want the video to play smoothly on slower
machines.
You might want to consider replace:
CGAffineTransformMakeRotation(90.0 * M_PI / 180.0)
with:
CGAffineTransformMake(0.0, 1.0, -1.0, 0.0, 0.0, 0.0)
Cheers,
Nicko
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden