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

OpenCV on Xojo

O_Brien__Brian
Beginner
465 Views

Anyone familiar with Xojo / RealBasic and the port of OpenCV to that environment?  I'm trying to use IPL to convert an RGB image to an RGBA image... should be pretty straight forward but I'm crashing...

This should be quite simple I have a memory block or RGB samples in a matrix form all packed no column rounding even or odd widths.

 

 

    // openCV
    // memoryblock can be used in place of Ptr for external lib 
    dim img4 as ptr
    dim size as CvSize
    dim depth as integer
    dim nchannels as integer
    dim matsize as integer
    dim hdrsize as integer
    dim img as MemoryBlock
    dim imgStruct as IplImage
    
    size.Height = dcmImg.mRows
    size.width = dcmImg.mColumns
    
    depth = dcmImg.mBitsStored
    nchannels = dcmImg.mSamplesPerPixel
    matsize = dcmImg.getPixelMemoryBlock.Size
    hdrsize = imgStruct.Size
    
    img = cvCreateImage(size,depth,nchannels)
    img.Ptr(108) = dcmImg.getPixelMemoryBlock
    img.ptr(68) = dcmImg.getPixelMemoryBlock
    
    // we need a 4 Channels image to be converted in Xojo BitMap Format
    img4=cvCreateImage(size,depth,4)
    
    if nChannels <=2 then
      dim img3 as ptr=cvCreateImage(size,depth,3)
      cvCvtColor(img,img3,CV_GRAY2BGR)
      cvCvtColor(img3,img4,CV_RGB2RGBA)
    else
      cvCvtColor(img,img4,CV_RGB2RGBA)
    end if
    
    // to reverse BGRA order for bitMap
    cvFlip(img4,img4, 0)
    // convert to Xojo
    // must be improved for 16 bits
    if depth>=16 then
      picture =convert2Picture(img)
    else
      picture=convert2BMP(img4) // Crashes here ...
    end if
    

 

0 Kudos
0 Replies
Reply