kid
August 10, 2007, 06:33:40
Hello.
I am a new user of IC Imaging......
My purpose is to do some image processing in every frame which gotten from camera . To do this, it sounds that there two ways , the first is that make a directshow filter,do the image processing in the filter, but I have no time to study filter ( it seems difficult....) . The second way can be this, make a timer, get 20(or more) frames in one second, then do some image processing in every frame, then draw it . I think the second way is not efficient, because it have to a lot work, in one second, it have to get the image, do the image processing, and draw it . Am I right ? And there are another way ?
The second question. I read the sample of the callback, and I changed it in soma place, first, I defined a
CD *pDC in the in CListener, and changed
int nLines = SetDIBitsToDevice( pDC->GetSafeHdc().........., and in put a IDC_Image1 (IDC_Static) in the dialog, in the ButtonClick
CWnd * pWndImage1;
CDC *pDCImage1;
pWndImage1=GetDlgItem(IDC_Image1);
pDCImage1=pWndImage1->GetDC();
pListener->pDC=pDCImage1;
So, I think it can draw every frame on the dialog, where is the error ? Thank you for your help.
void CImgProceDlg::OnBnClickedButton1()
{
m_pGrabber = new DShowLib::Grabber();
ASSERT( m_pGrabber );
m_pGrabber->showDevicePage();
if( m_pGrabber->isDevValid() )
{
m_pGrabber->setHWND( m_hWnd );
CListener *pListener = new CListener();
DShowLib::FrameHandlerSink::tFHSPtr m_pSink;
m_pSink = DShowLib::FrameHandlerSink::create(DShowLib::eRGB2 4, 5 );
m_pSink->setSnapMode( true );
m_pGrabber->setSinkType( m_pSink );
CWnd * pWndImage1;
CDC *pDCImage1;
pWndImage1=GetDlgItem(IDC_Image1);
pDCImage1=pWndImage1->GetDC();
pListener->pDC=pDCImage1;
m_pGrabber->addListener( pListener, GrabberListener::eFRAMEREADY|GrabberListener::eOVE RLAYCALLBACK );
m_pGrabber->startLive();
}
}
in CListener
I definded
public:
CDC * pDC;
void CListener::frameReady( Grabber& param, smart_ptr<MemBuffer> pBuffer, DWORD currFrame)
{
pBuffer->lock();
smart_ptr<BITMAPINFOHEADER> pInf = pBuffer->getBitmapInfoHeader();
BYTE *pPixel = pBuffer->getPtr();
unsigned int iBytecount = pInf->biWidth * pInf->biBitCount / 8 * pInf->biHeight;
for( unsigned int i = 0; i < iBytecount; i++)
{
*pPixel = (BYTE)(0xFF - (*pPixel));
pPixel++;
}
TRACE("aaaa\n");
// And we can do another image processing in here...... The image of output is the result of image processing, so we can do the image processing in every frame without using a timer to get n frames in one second..... Am I right?
int nLines = SetDIBitsToDevice( pDC->GetSafeHdc(),// Handle to the device
0,
0,
pInf->biWidth, // Source rectangle width
pInf->biHeight, // Source rectangle height
0, // X-coordinate of lower-left corner of the source rect
0, // Y-coordinate of lower-left corner of the source rect
0, // First scan line in array
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
);
pBuffer->unlock();
}
I am a new user of IC Imaging......
My purpose is to do some image processing in every frame which gotten from camera . To do this, it sounds that there two ways , the first is that make a directshow filter,do the image processing in the filter, but I have no time to study filter ( it seems difficult....) . The second way can be this, make a timer, get 20(or more) frames in one second, then do some image processing in every frame, then draw it . I think the second way is not efficient, because it have to a lot work, in one second, it have to get the image, do the image processing, and draw it . Am I right ? And there are another way ?
The second question. I read the sample of the callback, and I changed it in soma place, first, I defined a
CD *pDC in the in CListener, and changed
int nLines = SetDIBitsToDevice( pDC->GetSafeHdc().........., and in put a IDC_Image1 (IDC_Static) in the dialog, in the ButtonClick
CWnd * pWndImage1;
CDC *pDCImage1;
pWndImage1=GetDlgItem(IDC_Image1);
pDCImage1=pWndImage1->GetDC();
pListener->pDC=pDCImage1;
So, I think it can draw every frame on the dialog, where is the error ? Thank you for your help.
void CImgProceDlg::OnBnClickedButton1()
{
m_pGrabber = new DShowLib::Grabber();
ASSERT( m_pGrabber );
m_pGrabber->showDevicePage();
if( m_pGrabber->isDevValid() )
{
m_pGrabber->setHWND( m_hWnd );
CListener *pListener = new CListener();
DShowLib::FrameHandlerSink::tFHSPtr m_pSink;
m_pSink = DShowLib::FrameHandlerSink::create(DShowLib::eRGB2 4, 5 );
m_pSink->setSnapMode( true );
m_pGrabber->setSinkType( m_pSink );
CWnd * pWndImage1;
CDC *pDCImage1;
pWndImage1=GetDlgItem(IDC_Image1);
pDCImage1=pWndImage1->GetDC();
pListener->pDC=pDCImage1;
m_pGrabber->addListener( pListener, GrabberListener::eFRAMEREADY|GrabberListener::eOVE RLAYCALLBACK );
m_pGrabber->startLive();
}
}
in CListener
I definded
public:
CDC * pDC;
void CListener::frameReady( Grabber& param, smart_ptr<MemBuffer> pBuffer, DWORD currFrame)
{
pBuffer->lock();
smart_ptr<BITMAPINFOHEADER> pInf = pBuffer->getBitmapInfoHeader();
BYTE *pPixel = pBuffer->getPtr();
unsigned int iBytecount = pInf->biWidth * pInf->biBitCount / 8 * pInf->biHeight;
for( unsigned int i = 0; i < iBytecount; i++)
{
*pPixel = (BYTE)(0xFF - (*pPixel));
pPixel++;
}
TRACE("aaaa\n");
// And we can do another image processing in here...... The image of output is the result of image processing, so we can do the image processing in every frame without using a timer to get n frames in one second..... Am I right?
int nLines = SetDIBitsToDevice( pDC->GetSafeHdc(),// Handle to the device
0,
0,
pInf->biWidth, // Source rectangle width
pInf->biHeight, // Source rectangle height
0, // X-coordinate of lower-left corner of the source rect
0, // Y-coordinate of lower-left corner of the source rect
0, // First scan line in array
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
);
pBuffer->unlock();
}