- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't find anything to help me to overlay a png file over a video using IPP and Opencv.
I use Opencv in order to read video frames but i can't load a png file with ipp and overlay over my frame with my transparent png (i want to use the png alpha layer)
Can someone help me?
thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello tarifut,
You may have known that IPP provide some image processing functions, like ippiAlphaComp_8u_C3R(), whichcomposite two image buffers using either the opacity (alpha) channel in the images or provided alpha values. These functions operate on image buffers with 8-bit or 16-bit data in RGB or RGBA format. In
all compositing operations a resultant pixel in destination buffer pDst is created by overlaying
a pixel from the foreground image buffer pSrc1 over a pixel from the background image buffer
pSrc2.
Pleasefind more functions from IPP manual ippiman.pdf under
Butallipp functionsassume the image has been loaded into system memory. So if you have load both frame and png file insome memory buffer, you can select approprate IPP function to complete the functionality.
Lucky, OpenCV shouldprovide such load functions, right? . It canread video frame and load a png fileto some memory buffer, then employ IPP function to do any operation you wanted to do.
For example,Iload a png file andcopyit into another image. I writec code as below.
#include "stdafx.h"
#include
#include
#include "ipp.h"
#include "cv.h"
#include "highgui.h"
#include
#include "string.h"
using namespace std;
#define COMP 3
int main()
{
//int nFuncs=cvUseOptimized(1);
// cout<< "number of function optimized is" << nFuncs << endl;
//const char* opencv_libraries = 0;
//const char* addon_modules = 0;
//cvGetModuleInfo(0, &opencv_libraries,&addon_modules );
//printf( "OpenCV: %s\nAdd-on Modules: %s\n",opencv_libraries, addon_modules );
IplImage* dst;
CvSize cvsrcSize;
CvSize cvdstSize;
IppStatus status;
IplImage* src = cvLoadImage( "pic1.png", 1 ); //"ring.bmp"pic1.png
cvsrcSize=cvGetSize(src);
int w= cvsrcSize.width;
int h= cvsrcSize.height;
IppiRect srcRect = { 0, 0,w, h };
IppiSize srcSize = {w, h };
CvSize cvsrcTempSize={w, h};
IppiSize srcTempSize={w, h};
IplImage* srcTemp = cvCreateImage ( cvsrcTempSize,8, COMP);
//Ipp8u backValue[4]={255,255,255,0};
ippiSet_8u_C3R (0, (Ipp8u*) srcTemp->imageData, srcTemp->widthStep, srcTempSize );
status=ippiCopy_8u_C3R( (Ipp8u*) src->imageData, src->widthStep,
(Ipp8u*) srcTemp->imageData,,
srcTemp->widthStep,
srcSize);
return 0;
}
Hope it helps and let us know if any problem on using IPP function.
Best Regards,
Ying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may refer to the manual and make sure what parameter the function needed.
There is ippiAlphaCompC function call example code.
Example 5-7 Using Alpha Composition Function
IppStatus acomp( void ) {
Ipp8u imga[8*8], imgb[8*8], imgc[8*8];
IppiSize roi = { 8, 8 };
IppStatus st;
ippiImageRamp_8u_C1R( imga, 8, roi, 0, 1, ippAxsHorizontal );
ippiImageRamp_8u_C1R( imgb, 8, roi, 0, 2, ippAxsHorizontal );
st = ippiAlphaCompC_8u_C1R( imga, 8, 255/3, imgb, 8, 255, imgc, 8, roi, ippAlphaOver );
printf( "over: a=%d,A=255/3; b=%d,B=255; c=%d //
c=a*A+b*(1-A)*B\n",imga[6],imgb[6],imgc[6] );
return st;
}
Output
over: a=6,A=255/3; b=12,B=255; c=10 // c=a*A+b*B*(1-A)
IPP can't be used to load a file. what ever png or jpg.You may need to load them into memory bufferby openCV, then feed the correspoinding data pointer to ippiAlphaComp function.Sorry, we haven'tready opencv codefor you. Have you run into an exact question whencreate the code? (You may send me your code by private thread)
Regards,
Ying
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page