PDA

View Full Version : Problem with winEvent



franco.amato
18th August 2010, 19:23
Good morning,
I'm building a Qt application ( based on QDialog ) to catch and render frames from my uEye video camera ( IDS-Imaging ).
So I need to link with my application the sdk coming with the camera ( *.lib, *.h and relative dll ). Basically the sdk of the camera works with windows message ( that I would handle in the application and process ).
Firstly I have to initialize the camera and once I did it I install the messages I would catch so:


bool CameraView::EvInitAll()
{
// Enable Messages
is_EnableMessage( m_hCam, IS_DEVICE_REMOVED, reinterpret_cast<HWND>( this->winId() ) );
is_EnableMessage( m_hCam, IS_DEVICE_RECONNECTED, reinterpret_cast<HWND>( this->winId() ) );
is_EnableMessage( m_hCam, IS_FRAME, reinterpret_cast<HWND>( winId() ) );

return true;
}

This should install the following messages:
IS_DEVICE_REMOVED // happens when I disconnect the camera
IS_DEVICE_RECONNECTED // happens when I reconnect the camera
IS_FRAME // SHOULD happens when I receive frames from the camera

So I think to handle windows messages into a Qt application I should use winEvent.
So I reimplemented it in my app so:
In the *.h

protected:
virtual bool winEvent( MSG*, long* );

and in the *.cpp

bool CameraView::winEvent(MSG *m, long* result)
{
uint msgType = m->message; // test line

switch ( m->wParam )
{
case IS_DEVICE_REMOVED:
qDebug("Device removed");
break;
case IS_DEVICE_RECONNECTED:
qDebug("Device reconnected");
break;
case IS_FRAME:
qDebug("Frame received");
break;
}

return false;
}


Where ( from the camera sdk ):

#define IS_FRAME 0x0000
#define IS_DEVICE_REMOVED 0x1000
#define IS_DEVICE_RECONNECTED 0x0004

I have problems with the IS_FRAME message. Seems that it occurs always.
No problem with the IS_DEVICE_REMOVED and IS_DEVICE_RECONNECTED. When I disconnect the camera I can see the Device removed string at shell ( the same with the IS_DEVICE_RECONNECTED ).
But When I start the application the IS_FRAME is immediately handled ( this should not be possible as I first have to initialize the camera ).
It immediately starts to print a shell Frame received and it should not. Also when I move the mouse it prints Frame received. Why this message is always handles when I don't effectively receive frames from the camera?

I hope to get help.

Here a list of some of the camera messages:

// ----------------------------------------------------------------------------
// Window message defines
// ----------------------------------------------------------------------------
#define IS_UEYE_MESSAGE (WM_USER + 0x0100)
#define IS_FRAME 0x0000
#define IS_SEQUENCE 0x0001
#define IS_TRIGGER 0x0002
#define IS_TRANSFER_FAILED 0x0003
#define IS_DEVICE_RECONNECTED 0x0004
#define IS_MEMORY_MODE_FINISH 0x0005
#define IS_FRAME_RECEIVED 0x0006
#define IS_GENERIC_ERROR 0x0007
#define IS_STEAL_VIDEO 0x0008
#define IS_WB_FINISHED 0x0009
#define IS_AUTOBRIGHTNESS_FINISHED 0x000A
#define IS_OVERLAY_DATA_LOST 0x000B

#define IS_DEVICE_REMOVED 0x1000
#define IS_DEVICE_REMOVAL 0x1001
#define IS_NEW_DEVICE 0

Best Regards,
Franco

alexisdm
19th August 2010, 00:49
Shouldn't you test if it is actually a uEye message ?


bool CameraView::winEvent(MSG *m, long* result)
{
uint msgType = m->message;

if (msgType != IS_UEYE_MESSAGE)
return false; // Let Qt handle other messages

switch ( m->wParam )
{
...
}
return true;
}

franco.amato
19th August 2010, 16:07
Shouldn't you test if it is actually a uEye message ?


bool CameraView::winEvent(MSG *m, long* result)
{
uint msgType = m->message;

if (msgType != IS_UEYE_MESSAGE)
return false; // Let Qt handle other messages

switch ( m->wParam )
{
...
}
return true;
}

It worked.
Thank you

m-obi
17th February 2016, 22:56
Hello,

i'm new at using uEye in Qt. Can you show your entire cpp please?