View Full Version : How To Display The Processed Buffer
August 10, 2011, 12:25:21
I have processed the Membuffer in the FrameReady of the Listenner.Now I want to display the result buffer,but I can't find the method from the User's Guide.Could you give me some advice?
August 11, 2011, 09:31:42
to display the processed buffer, please refer to the code sample below. You can create a sample on your own, by building a new IC Dialog Application with the Visual Studio project wizard and select "Do image processing" and "show processed image" on the options page of the wizard.
// Callback handler.
void CListener::frameReady( Grabber& param, smart_ptr<MemBuffer> pBuffer, DWORD FrameNumber)
DoImageProcessing( pBuffer );
// Draw the image buffer into the DrawCWnd.
void CListener::DrawBuffer( smart_ptr<MemBuffer> pBuffer)
if( m_pDrawCWnd != NULL)
if( pBuffer != 0 )
CDC *pDC = m_pDrawCWnd->GetDC();
smart_ptr<BITMAPINFOHEADER> pInf = pBuffer->getBitmapInfoHeader();
int nLines = StretchDIBits( pDC->GetSafeHdc(),// Handle to the device
m_WindowSize.cx, // Dest. rectangle width.
m_WindowSize.cy, // Dest. rectangle height.
0, // X-coordinate of lower-left corner of the source rect.
0, // Y-coordinate of lower-left corner of the source rect.
pInf->biWidth, // Source rectangle width.
pInf->biHeight, // Number of scan lines.
pBuffer->getPtr(), // Modified address of array with DIB bits.
reinterpret_cast<LPBITMAPINFO>( &*pInf ), // Address of structure with bitmap info.
DIB_RGB_COLORS, // RGB or palette indices.
August 11, 2011, 17:36:36
August 12, 2011, 06:30:20
Now I meet a new question.I have three camera,and in the program I have set three grabber pointers and three listeners fasten on each grabber. Then I add the code into the listener class as Michael suggested.The listeners fastened on grabber2 and grabber3 can work well,and we can see the processed pictures display on screen ,however the listener fastened on grabber1 cannot display on the screen.What should I do?
Ps:The three listeners and the three grabbers are equipollence.
August 12, 2011, 09:53:40
I am very sorry, but I do not really understand your problem. Would you please create a sample project that reproduces the issue and send it to me?
August 12, 2011, 13:12:40
I have posted the sample codes in the attachment.Waiting for your answer.
August 12, 2011, 13:31:10
I have posted the sample codes in the attachment.Waiting for your answer.1410
August 12, 2011, 14:31:24
what cameras do you have and how do you connect them to your computer?
August 12, 2011, 17:20:14
The cameras are DMK 31BG03.H.The GigE cameras.They work well when we just use the function startlive(true);.
August 15, 2011, 13:17:02
I had a look into your sample source code. I think, you want to display the three live videos in one window. Therefore, you pass the window handle of your view window to the listener, which stores it in the n_pDrawWindow member. However, in your CameraSet.CPP you also pass the same handle to the grabber object. This will cause many flickering, therefore, I suggest to remove the part
pGrabber->setHWND( m_hWnd );
// Set the new window size
Since you display the video images in the Listener, you do following at the same position:
if( pGrabber->isDevValid() )
You will encounter problems, if you write in the DC of the drawwindow from different positions at the same point of time. That means, you have three listeners writing on the DC at the same time. This is not recommended and can cause problems.
You may do not draw tne video image in the Listener. You may setup a timer with 15ms intervall. In the timer event you check with m_pSinkx->getLastAcqMemBuffer()->getLastAcqMemBuffer() whether the index in the ringbuffer has changed. This indicates a new image. If so, you lock the image buffer and draw it, as you did in the Listener. You proceed in sequence with your three grabber objects. This makes sure, that you do not have double access to the windows's DC.
Pleasy try to implement this first.
August 16, 2011, 05:57:37
Thank you for your advice.I will have a try.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.