Wowza Community

Get image from WZCameraView

Dear Wowza team,

I’m trying to get periodic screenshots from the WZCameraView to compare them and determine wether or not something has changed on the current stream.

In order to achieve this, the first step would be to get a Bitmap Image, which is possible on a regular SurfaceView, from which WZCameraView extends.

It is even easier to achieve this from a TextureView, simply by calling getBitmap().

Any advice on how to achieve this with WZCameraView’s current implementation?

Thank you :slight_smile:


You should be able to use the registered video sink handler to obtain an image reference for the frame, which you can then manipulate as needed. Here is an example where the image is attached as an overlay on the screen:

- (void) videoFrameWasCaptured:(nonnull CVImageBufferRef)imageBuffer framePresentationTime:(CMTime)framePresentationTime frameDuration:(CMTime)frameDuration {
            // _shouldCaptureImage is a class variable that is enabled/disabled
            // by a button press.  You don't want this updated every frame, it would get a bit insane.
                // get frame reference as ciimage
                CIImage *frameImage = [[CIImage alloc] initWithCVImageBuffer:imageBuffer];
                CIContext *temporaryContext = [CIContext contextWithOptions:nil];
                // get the cgimageref to inevitably conver to uiimage.
                CGImageRef videoImage = [temporaryContext
                                         fromRect:CGRectMake(0, 0,
                // get uiimage and set the overlay position (just for
                UIImage *image = [[UIImage alloc] initWithCGImage:videoImage];
                capView.frame = CGRectMake(50,10, 40, 40);
                // modify image on main thread
                dispatch_async(dispatch_get_main_queue(), ^{
                    capView.image = image;
                    // if uiimageview already exists, you should just update it 
                    // vs add another subview like we are doing here.  
                    [self.view addSubview:capView];