I am capturing every frame of vide output and by processing it, I add a CALayer to an overlay which should be transformed according to the results from processing the frame.
That CALayer basically knows how to draw an arrow. If I just add the CALayer on every frame it works, but if I apply a transform on it, it will not show at all.
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
dispatch_async(dispatch_get_main_queue(), ^(void)
{
firstLayer.transform = CATransform3DMakeRotation(M_PI_2, 1, 0, 0);
[firstLayer setNeedsDisplay];
});
}
What is wrong? How can I make the overlay show the layer transformed on each frame?
You are rotating your layer by π/2 radians (90°) around the X axis, making your layer seem completely invisible because you are looking at it exactly edge-on.
I'm assuming you meant to rotate it by 90° on the Z axis, the axis that you can think of as pointing in/out of the screen. If this is what you meant to do, then rotate around this axis instead, like this: