Results 1 to 3 of 3

Thread: DFK 22BUC03 testing (OpencV, GPIO and Frames/second)

  1. #1
    Join Date
    Dec 2016
    Posts
    2

    Question DFK 22BUC03 testing (OpencV, GPIO and Frames/second)

    Hi Stefan

    I have tested DFK 22BUC03, I would like to do the following points:
    - Software by OpenCv
    - Depend on the algoritm use an external output to active a sensor.
    I have used the example MemBuffer in OpenCv but the system is not quick enough, I couldn’t get 50 frames/second.
    Here you are the configuration I have selected:

    - 320x240 pixels B/N and also (RGB24).
    -Exposure time 1/5000 s.
    -Nº frames: 160


    Please take a look the following script, I only need to test the camera and check if it is enough quick according to the points above. Also I included the configuration of Serial port in order to test an external signal to a simple hardware (Arduino), instead of use GPIO port, according to specifications this camera could use GPIO, but I only found Strobbe function, please clarify If this option is available and How can I use it?

    I am pretty sure the script is not the most efficiency, maybe there is something wrong, I think the “for loop” is not the best way.
    There are not too much information about OpenCv and IS.

    Finally, could you provide a simple script in OpenCV to test the speed of the camera and GPIO port?

    Script en C++:

    ///////////////////////////////////////////////////////////////////////////////
    // This example demonstrates how to setup a MemBuffer collection and use it to
    // capture images.

    #define _WIN32_WINNT 0x0500
    #include <iostream>

    #include <C:\Users\Antonio\Documents\IC Imaging Control 3.4\classlib\include\tisudshl.h>
    #include <C:\Users\Antonio\Documents\IC Imaging Control 3.4\samples\vc10\Common\CmdHelper.h>
    #include <opencv2\opencv.hpp>
    #include <Windows.h>
    #include "SerialClass.h"

    using namespace _DSHOWLIB_NAMESPACE;
    using namespace cv;
    using namespace std;


    int main(int argc, char* argv[])
    {

    //Serial Port configuration
    //Send a character in order to test external communication with hw Arduino
    char palabra[] = "A";
    //
    Serial* Arduino = new Serial("COM3");
    //while (Arduino->IsConnected()) {

    // Initialize the library.
    DShowLib::InitLibrary();

    Grabber grabber;
    if( !setupDeviceFromFile( grabber ) )
    {
    return -1;
    }

    grabber.setOverlayBitmapPathPosition( ePP_NONE );

    // Set the image buffer format to RGB24.
    // Let the sink create a matching MemBufferCollection with 1 buffer.
    //tFrameHandlerSinkPtr pSink = FrameHandlerSink::create( eY800, 1 );
    tFrameHandlerSinkPtr pSink = FrameHandlerSink::create(eRGB24, 1);
    //tFrameHandlerSinkPtr pSink = FrameHandlerSink::create(eRGB8, 1);

    // We use snap mode.
    pSink->setSnapMode( true );

    // Set the sink.
    grabber.setSinkType( pSink );

    //// Prepare the live mode, to get the output size if the sink.
    if( !grabber.prepareLive( false ) )
    {
    std::cerr << "Could not render the VideoFormat into a eY800 sink.";
    return -1;
    }

    // Retrieve the output type and dimension of the handler sink.
    // The dimension of the sink could be different from the VideoFormat, when
    // you use filters.
    FrameTypeInfo info;
    pSink->getOutputFrameType( info );

    BYTE* pBuf[1];
    // Allocate 5 image buffers of the above calculate buffer size.
    for( int i = 0; i < 1; ++i )
    {
    pBuf[i] = new BYTE[info.buffersize];
    }

    // Create a new MemBuffer collection that uses our own image buffers.
    tMemBufferCollectionPtr pCollection = MemBufferCollection::create( info, 1, pBuf );
    if( pCollection == 0 || !pSink->setMemBufferCollection( pCollection ) )
    {
    std::cerr << "Could not set the new MemBufferCollection, because types do not match.";
    return -1;
    }

    //************************************************** **************************************
    // 100 frames to test
    for (int j = 0; j < 100; ++j)
    {

    // Start live mode for fast snapping. The live video will not be displayed,
    // because false is passed to startLive().
    grabber.startLive( false );

    // Snap 1 image. The images are copied to the MemBufferCollection the
    // application created above.
    pSink->snapImages( 1 );

    // Stop the live video.
    grabber.stopLive();

    //Monitorizamos con OpenCV la captura
    //Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC1, Scalar(0));
    Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC3);
    memcpy(newImg.ptr(), pBuf[0], info.buffersize);
    imshow("cap", newImg);

    // Send a character to Arduino
    Arduino->WriteData(palabra, sizeof(palabra) - 1);

    //Esperamos 1 ms
    //waitKey(1);

    }
    //************************************************** **************************************

    // Close the device.
    grabber.closeDev();

    return 0;
    }

  2. #2
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,862

    Re: DFK 22BUC03 testing (OpencV, GPIO and Frames/second)

    Hello

    Your code at
    Code:
    for (int j = 0; j < 100; ++j)
    {
    
    // Start live mode for fast snapping. The live video will not be displayed,
    // because false is passed to startLive().
    grabber.startLive( false );
    
    // Snap 1 image. The images are copied to the MemBufferCollection the
    // application created above.
    pSink->snapImages( 1 );
    
    // Stop the live video.
    grabber.stopLive();
    
    //Monitorizamos con OpenCV la captura
    //Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC1, Scalar(0));
    Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC3);
    memcpy(newImg.ptr(), pBuf[0], info.buffersize);
    imshow("cap", newImg);
    
    // Send a character to Arduino
    Arduino->WriteData(palabra, sizeof(palabra) - 1);
    
    //Esperamos 1 ms
    //waitKey(1);
    
    }
    Is indeed slow. Move the start and stop outside the loop:
    // Start live mode for fast snapping. The live video will not be displayed,
    // because false is passed to startLive().
    grabber.startLive( false );

    Code:
    for (int j = 0; j < 100; ++j)
    {
    
    // Snap 1 image. The images are copied to the MemBufferCollection the
    // application created above.
    pSink->snapImages( 1 );
    
    // Stop the live video.
    
    //Monitorizamos con OpenCV la captura
    //Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC1, Scalar(0));
    Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC3);
    memcpy(newImg.ptr(), pBuf[0], info.buffersize);
    imshow("cap", newImg);
    
    // Send a character to Arduino
    Arduino->WriteData(palabra, sizeof(palabra) - 1);
    
    //Esperamos 1 ms
    //waitKey(1);
    
    }
    grabber.stopLive();
    Finally, could you provide a simple script in OpenCV to test the speed of the camera and GPIO port?
    No. That is not part of what OpenCV can do.

    The GPOut is the same pin as the strobe. And both are Open Drain / Open Collector, not TTL
    Best regards
    Stefan
    IC Imaging Control Support

  3. #3
    Join Date
    Dec 2016
    Posts
    2

    Re: DFK 22BUC03 testing (OpencV, GPIO and Frames/second)

    Quote Originally Posted by Stefan Geissler View Post
    Hello

    Your code at
    Code:
    for (int j = 0; j < 100; ++j)
    {
    
    // Start live mode for fast snapping. The live video will not be displayed,
    // because false is passed to startLive().
    grabber.startLive( false );
    
    // Snap 1 image. The images are copied to the MemBufferCollection the
    // application created above.
    pSink->snapImages( 1 );
    
    // Stop the live video.
    grabber.stopLive();
    
    //Monitorizamos con OpenCV la captura
    //Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC1, Scalar(0));
    Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC3);
    memcpy(newImg.ptr(), pBuf[0], info.buffersize);
    imshow("cap", newImg);
    
    // Send a character to Arduino
    Arduino->WriteData(palabra, sizeof(palabra) - 1);
    
    //Esperamos 1 ms
    //waitKey(1);
    
    }
    Is indeed slow. Move the start and stop outside the loop:
    // Start live mode for fast snapping. The live video will not be displayed,
    // because false is passed to startLive().
    grabber.startLive( false );

    Code:
    for (int j = 0; j < 100; ++j)
    {
    
    // Snap 1 image. The images are copied to the MemBufferCollection the
    // application created above.
    pSink->snapImages( 1 );
    
    // Stop the live video.
    
    //Monitorizamos con OpenCV la captura
    //Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC1, Scalar(0));
    Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC3);
    memcpy(newImg.ptr(), pBuf[0], info.buffersize);
    imshow("cap", newImg);
    
    // Send a character to Arduino
    Arduino->WriteData(palabra, sizeof(palabra) - 1);
    
    //Esperamos 1 ms
    //waitKey(1);
    
    }
    grabber.stopLive();

    No. That is not part of what OpenCV can do.

    The GPOut is the same pin as the strobe. And both are Open Drain / Open Collector, not TTL
    Hi Stefan,

    Exactly the code is working, and we have tested succesfully the camera, but I would like to ask you if you could provide a specific hardware to process 50 frames/sec, the final code is more complex and we only get 50 frames/sec with a high level of computer. I am pretty sure there is a more simple computer which we can get 50 frames/sec. Could you recommend hardware to get it?

    Thanks.

Similar Threads

  1. Double frames. Blank frames
    By sniperpride in forum Hardware and Driver
    Replies: 8
    Last Post: September 24, 2014, 07:43:15
  2. DMM 72BUC02-ML GPIO Output
    By epetriinc in forum Hardware and Driver
    Replies: 1
    Last Post: July 18, 2013, 10:02:40
  3. More GPIO?
    By MarcvD in forum Hardware and Driver
    Replies: 1
    Last Post: March 4, 2013, 09:34:30
  4. Use GPIO as strobe / GPIO Latency
    By JamesF in forum Hardware and Driver
    Replies: 1
    Last Post: August 31, 2011, 17:28:43
  5. IC control + opencv (show and save color video with opencv)
    By moisdc in forum IC Imaging Control C++ Class Library
    Replies: 2
    Last Post: February 28, 2011, 11:54:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •