How do you integrate VisualApplets with OpenCV ?

  • Hi Mike

    welcome to the forum and thank you for the question. Others might have this question, too. I don't have my own example right now but let me share the example of a collegue. Maybe he can add some more information.


    Files

    • GrabToCV.zip

      (5.84 kB, downloaded 5 times, last: )

    Johannes Trein
    Teamleader Applications and Development
    SiliconSoftware GmbH
    https://silicon.software/wp-content/uploads/siso-logo-animation.gif



  • Thank you for providing the OpenCV code. I am using the C# wrapper and am having trouble converting the SisoImage data type into a Mat or a Bitmap Image type.


    C++ Code: (your code works)

    char* dataBuffer = (char*)Fg_getImagePtrEx(fg,lastPicNr,0,pMem0); //getBufferOfPhoto();

    Mat any_img(Size(width, height), CV_8UC1, dataBuffer, Mat::AUTO_STEP);

    imshow( "Display window raw", any_img );


    C# Code: (my code which does not work)

    SisoImage sisoImage = SiSoCsRt.Fg_getImagePtrEx( data.fg, (int)( imgNr ), data.port, data.mem);

    IntPtr dataBuffer = sisoImage.asPtr();

    Image<Gray, Byte> imgToDisplay = new Image<Gray, Byte>( 512, 2048 );

    imgToDisplay.Ptr = dataBuffer;

    CvInvoke.imshow( "Display window raw", imgToDisplay);


    I also tried this to get a Bitmap but this also did not work as it is not able to convert the SisoImage type:

    Image img = (Bitmap)(new ImageConverter()).ConvertFrom(dataBuffer);


    Also, the SisoCsRt.DrawBuffer() is able to write images to the created display (i.e. SisoCsRt.CreateDisplay() ) but is it possible to draw directly to a panel object on a Form?

  • Here in the C# wrapper documentation it is mentioned that the void* type is changed to SisoImage.


    SisoImage.toByteArray(uint imageSize)


    The above function is mentioned at the end of the page, but will give you the byte array representation.

    Based on the byte array it should be possible to create a openCV Mat / Image without copy.


    Björn RuddeMicroSiSo.png
    Senior Technical Sales and
    Field Application Engineer

    please:thumbup: