I have finally found a simple way of doing it.

- (void)captureOutput:(AVCaptureOutput *)captureOutput 
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer 
fromConnection:(AVCaptureConnection *)connection
{
    CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);

    CVPixelBufferLockBaseAddress(imageBuffer, kCVPixelBufferLock_ReadOnly);

    CIImage *ciImage = [CIImage imageWithCVPixelBuffer:imageBuffer];
    CIContext *temporaryContext = [CIContext contextWithOptions:nil];
    CGImageRef videoImage = [temporaryContext createCGImage:ciImage 
fromRect:CGRectMake(0, 0, CVPixelBufferGetWidth(imageBuffer), 
CVPixelBufferGetHeight(imageBuffer))];

    QPixmap pm = QtMac::fromCGImageRef(videoImage);

    CVPixelBufferUnlockBaseAddress(imageBuffer, kCVPixelBufferLock_ReadOnly);
}

Nuno

> On 29 Feb 2020, at 09:09, Jason H <jh...@gmx.com> wrote:
> 
> [replying to the list this time]
> 
> I don't know if it is possible, but if CoreVideo can't do it OpenCV could 
> probably do it. Not sure if 2vuy is in their list. Have a look at 
> https://docs.opencv.org/3.4/d8/d01/group__imgproc__color__conversions.html#ga4e0972be5de079fed4e3a10e24ef5ef0
> 
> This should be hardware accelerated to some degree...
> 
> 
>> Sent: Friday, February 28, 2020 at 7:26 PM
>> From: "Thiago Macieira" <thiago.macie...@intel.com>
>> To: interest@qt-project.org
>> Subject: Re: [Interest] Converting CVImageBufferRef into QImage
>> 
>> On Friday, 28 February 2020 09:57:31 PST Nuno Santos wrote:
>>> Thiago,
>>> 
>>> kCVPixelFormatType_422YpCbCr8     = '2vuy',     /* Component Y'CbCr 8-bit
>>> 4:2:2, ordered Cb Y'0 Cr Y'1 */
>>> 
>>> Missing your incredible replies already... You ROCK! :)
>>> 
>>> The question is still pertinent in the Qt domain since there is no direct
>>> way of constructing a QImage from 2vuy color space.
>> 
>> Then you convert yourself or via some HW acceleration.
>> 
>> You may be able to ask CV to convert to ARGB32 in HW for you.
>> 
>> --
>> Thiago Macieira - thiago.macieira (AT) intel.com
>>  Software Architect - Intel System Software Products
>> 
>> 
>> 
>> _______________________________________________
>> Interest mailing list
>> Interest@qt-project.org
>> https://lists.qt-project.org/listinfo/interest
>> 
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to