Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

OpenCV Development

rameshkannan
Beginner
865 Views
Hi there,

I am working in an image processing application. I need to process the gray image (of size 640 X 480) at the speed of 50 frames per second. Previously I thought to go with Intel instruction set for faster execution. Then I came to know about OpenCV and used it. Now I need to know whether all OpenCV functions developed using Intel instruction set? Please let me know the info.

Thanks in advance,
Rameshkannan
0 Kudos
11 Replies
Vladimir_Dudnik
Employee
865 Views
Hello,

As you probably know, OpenCV can call IPP functions internally if you have IPP installed on your system. Although, not all OpenCV functions have IPP counterparts.

What kind of processing do you want to do with your image?

Regards,
Vladimir
0 Kudos
Ying_H_Intel
Employee
865 Views
Hi Rameshkannan,

one more informationfor yourreference,
IPP and OpenCV FAQ :
http://software.intel.com/en-us/articles/intel-integrated-performance-primitives-intel-ipp-open-source-computer-vision-library-opencv-faq/

And OpenCV forum may be found from http://sourceforge.net/projects/opencvlibrary/ .


As I understand,you need image processing functions whichare optimized by Intel instruction set like SSE, thenIPPshould include direct image processing function like ippiFilter_8u_C1R() to processto grey image, please see more functions listin the IPP manual at

http://software.intel.com/en-us/articles/intel-integrated-performance-primitives-documentation/

Regards,
Ying H.
0 Kudos
Rajendra_S_
Beginner
865 Views

I wanted to detect face from a web camera. I found an example of face detection in samples folder.But they have provided a wrapper class called as CIppiImage . I am retriving frame using open cv,so I am not able to figure out that How I will be able to convert Mat Image or IplImage to the type of CIppiImage

0 Kudos
SergeyKostrov
Valued Contributor II
865 Views
>>...How I will be able to convert Mat Image or IplImage to the type of CIppiImage... I consider that question as a generic ( C++ related ) and you need to use a C++ operator = for the CIppiImage class.
0 Kudos
SergeyKostrov
Valued Contributor II
865 Views
Rajendra, I've looked at all your five, or so, posts with the same question. If you post a test case that has some codes for IplImage structure and CIppiImage class then I will help you with implementation of a conversion C++ operator.
0 Kudos
Rajendra_S_
Beginner
865 Views

    CIppiImage *dst=new CIppiImage();

where dst is the object for CIppiImage .

Definition of CIppiImage :::

class CIppiImage : public CImgHeader
{
public:
    CIppiImage();
   CIppiImage(const CIppiImage& img);
    virtual ~CIppiImage();
    CIppiImage& operator =(const CIppiImage& image);

// General Operations
   // Set image header and allocate data
    BOOL CreateImage(int width, int height, int nChannels = 3, ppType type = pp8u, BOOL bPlane = FALSE);
    BOOL CreateImage(CImgHeader header);
   // Load image from bmp file
   BOOL LoadImage(CFile* pFile);
   // Save image to bmp file
   BOOL SaveImage(CFile* pFile);
   // Reset image size
   BOOL SetSize(int width, int height);

// Attributes
   // Get image header
   CImgHeader GetHeader() const { return *(CImgHeader*)this;}
   // Get pointer to data
   void* DataPtr();
   // Get image size
   IppiSize Size() const { IppiSize size = {Width(), Height()}; return size;}
   // Get scanline size in bytes
   int  Step() const;
   // Get data size in bytes
   int  DataSize() const;
   // Get image width
   int  Width() const { return m_width;}
   // Get image height
   int  Height() const { return m_height;}
   // Get number of image channels
   int  Channels() const { return m_channels;}
   // Get plane order flag
   BOOL Plane() const { return m_plane;}
   // Get data type
   ppType Type() const { return m_type;}
   // Get size of data element in bits
   int Depth() const { return m_type & PP_MASK;}
   // Get signed data flag
   BOOL Sign() const { return m_type & PP_SIGN ? TRUE : FALSE;}
   // Get float data flag
   BOOL Float() const { return m_type & PP_FLOAT ? TRUE : FALSE;}
   // Get complex data flag
   BOOL Complex() const { return m_type & PP_CPLX ? TRUE : FALSE;}
   // Get string with data type description
   CString TypeString() const;
   // Get string with channels and plane description
   CString ChannelString() const;
   // Set data changed / unchanged flag
   // This flag must be set to TRUE if data has been changed
   // Then CView::OnDraw function will update bitmap and
   // set this flag to FALSE
   void IsUpdated(BOOL updated) {m_Updated = updated;}
   // Get data changed / unchanged flag
   // Used by CView::OnDraw function
   BOOL IsUpdated() const {return m_Updated;}
protected:
   void*     m_pData;
   BOOL      m_Updated;
    void Reset();
   void AllocateData();
   void FreeData();
};

Now for IplImage ::

IplImage * frame2;

Where frame2 is the object.

Definition of IplImage

typedef struct _IplImage
{
    int  nSize;             /* sizeof(IplImage) */
    int  ID;                /* version (=0)*/
    int  nChannels;         /* Most of OpenCV functions support 1,2,3 or 4 channels */
    int  alphaChannel;      /* Ignored by OpenCV */
    int  depth;             /* Pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S,
                               IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported.  */
    char colorModel[4];     /* Ignored by OpenCV */
    char channelSeq[4];     /* ditto */
    int  dataOrder;         /* 0 - interleaved color channels, 1 - separate color channels.
                               cvCreateImage can only create interleaved images */
    int  origin;            /* 0 - top-left origin,
                               1 - bottom-left origin (Windows bitmaps style).  */
    int  align;             /* Alignment of image rows (4 or 8).
                               OpenCV ignores it and uses widthStep instead.    */
    int  width;             /* Image width in pixels.                           */
    int  height;            /* Image height in pixels.                          */
    struct _IplROI *roi;    /* Image ROI. If NULL, the whole image is selected. */
    struct _IplImage *maskROI;      /* Must be NULL. */
    void  *imageId;                 /* "           " */
    struct _IplTileInfo *tileInfo;  /* "           " */
    int  imageSize;         /* Image data size in bytes
                               (==image->height*image->widthStep
                               in case of interleaved data)*/
    char *imageData;        /* Pointer to aligned image data.         */
    int  widthStep;         /* Size of aligned image row in bytes.    */
    int  BorderMode[4];     /* Ignored by OpenCV.                     */
    int  BorderConst[4];    /* Ditto.                                 */
    char *imageDataOrigin;  /* Pointer to very origin of image data
                               (not necessarily aligned) -
                               needed for correct deallocation */
}

0 Kudos
SergeyKostrov
Valued Contributor II
865 Views
... class CIppiImage : public CImgHeader { ... // Attributes // Get image header CImgHeader GetHeader() const { return *(CImgHeader*)this;} // Get pointer to data void* DataPtr(); ... void* m_pData; ... }; ... typedef struct _IplImage { ... char *imageData; ... } IplImage; A conversion could be easily done directly ( you have CImgHeader ) or with C++ operators =, >> or <<.
0 Kudos
Rajendra_S_
Beginner
865 Views

Can you please write that code ? it will be a great help.

0 Kudos
SergeyKostrov
Valued Contributor II
865 Views
>>Can you please write that code ? Sorry, No. However, I'll post a test case and you will be able to learn how to use C++ operators for object conversions, etc.
0 Kudos
SergeyKostrov
Valued Contributor II
865 Views
// Sub-Test 10 - Copy a Class1 attribute to a Class2 attribute // Version 1 - CTestDMIPImage1 -> CTestImage1 class CTestDMIPImage1 { public: CTestDMIPImage1( RTvoid ) { m_piData = ( RTint * )CrtNew RTint[2]; m_piData[0] = 555; m_piData[1] = 777; }; virtual ~CTestDMIPImage1( RTvoid ) { if( m_piData != RTnull ) { CrtDeleteEx( m_piData ); m_piData = RTnull; } }; RTint *m_piData; }; class CTestImage1 { public: CTestImage1( RTvoid ) { m_piData = RTnull; }; virtual ~CTestImage1( RTvoid ){}; CTestImage1 & operator=( const CTestDMIPImage1 &tdim ) { m_piData = tdim.m_piData; return ( CTestImage1 & )*this; }; CTestImage1 & operator>>=( CTestDMIPImage1 &tdim ) { tdim.m_piData = m_piData; return ( CTestImage1 & )*this; }; RTint *m_piData; }; // Version 2 - CTestImage2 -> CTestDMIPImage2 class CTestImage2 { public: CTestImage2( RTvoid ) { m_piData = ( RTint * )CrtNew RTint[2]; m_piData[0] = 777; m_piData[1] = 555; }; virtual ~CTestImage2( RTvoid ) { if( m_piData != RTnull ) { CrtDeleteEx( m_piData ); m_piData = RTnull; } }; RTint *m_piData; }; class CTestDMIPImage2 { public: CTestDMIPImage2( RTvoid ) { m_piData = RTnull; }; virtual ~CTestDMIPImage2( RTvoid ){}; CTestDMIPImage2 & operator=( const CTestImage2 &tim ) { m_piData = tim.m_piData; return ( CTestDMIPImage2 & )*this; }; CTestDMIPImage2 & operator>>=( CTestImage2 &tim ) { tim.m_piData = m_piData; return ( CTestDMIPImage2 & )*this; }; RTint *m_piData; };
0 Kudos
SergeyKostrov
Valued Contributor II
865 Views
... // Sub-Test 10 - Copy a Class1 attribute to a Class2 attribute { CrtPrintf( RTU("Sub-Test 10\n") ); // Version 1 - CTestDMIPImage1 -> CTestImage1 CTestDMIPImage1 tdim1; CTestImage1 tim1; tim1 = tdim1; CrtPrintf( RTU("%ld %ld\n"), tim1.m_piData[0], tim1.m_piData[1] ); tdim1.m_piData[0] = 111; tdim1.m_piData[1] = 333; tim1 >>= tdim1; CrtPrintf( RTU("%ld %ld\n"), tim1.m_piData[0], tim1.m_piData[1] ); // Version 2 - CTestImage2 -> CTestDMIPImage2 CTestImage2 tim2; CTestDMIPImage2 tdim2; tdim2 = tim2; CrtPrintf( RTU("%ld %ld\n"), tdim2.m_piData[0], tdim2.m_piData[1] ); tdim2.m_piData[0] = 222; tdim2.m_piData[1] = 444; tdim2 >>= tim2; CrtPrintf( RTU("%ld %ld\n"), tdim2.m_piData[0], tdim2.m_piData[1] ); } ...
0 Kudos
Reply