Ask Your Question

Kroumvud's profile - activity

2014-05-05 18:04:01 -0500 asked a question Picture in Picture CPU Usagr

Hi all, I'm using OpenCV 2.4.7 under Mac OS and I trying to create application where I can mix images from two video sources. Now for mixing I'm use ROI logic for IplImage objects. For testing I'm try to mix two images 720 x 400 -(OSStatus)drawFrame:(BOOL)bDoDraw sourceImage:(IplImage *)pFrame destenationImage:(IplImage *)pDst withSettings:(InputSettings &)settings { OSStatus result = 0; IplImage *resImage = NULL; if (0 == settings.size.width || 0 == settings.size.height || !bDoDraw) { return result; }

try {
    //create templorary image
    resImage = cvCreateImage( cvSize(settings.size.width, settings.size.height), pFrame->depth, pFrame->nChannels);

    // resize
    cvResize(pFrame, resImage, 0);

    // set ROI
    cvSetImageROI(pDst, cvRect(settings.pos.x, settings.pos.y, settings.size.width, settings.size.height));
    cvSetImageROI(resImage, cvRect(0,0, m_resOutput.width - settings.pos.x, m_resOutput.height - settings.pos.y));

    // reset

    // Copy image
    if (pDst->nChannels != resImage->nChannels && 3 == resImage->nChannels)

        IplImage * resImage1 = cvCreateImage( cvSize(settings.size.width, settings.size.height), pDst->depth, pDst->nChannels);
        cvCvtColor(resImage, resImage1, CV_RGB2RGBA);
        cvCopy(resImage1, pDst);

        // reset ROI
        cvCopy(resImage, pDst);

        // reset ROI
catch (...)
    result = -2254;
    NSLog(@"Failed with mixing images");
return result;


With this logic mixing work perfect on my machine but it's take VERY MUCH CPU resources image description

On developer machine (CPU i5 3,1 GHz) everything fine and works properly, but on the Mac Book application work very slow and cannot mix images. So... is there another ways for mix two images with low CPU usage? Can I do this via GPU? Whether this provides an improvement in the work on the client side?

Thank you.