891130 - capturing an image from a camera
-
Application A was using C.dll as an interface for camera. C.dll was and is erroneous. Sometimes it throws exceptions and causes the application to crash. Since the application is intended to be running always in the platform and is responsible for many things as well as handling cameras, we decided to use in indirect method for the application to use the camera. The plan was to separate the dll from the application. Another application got responsible for getting involved with sending the appropriate commands to the camera via the dll and in another side be in communication with the application. We call it server. The application is now a client for it. The communication between these two separate processes is established via a named pipe. I've tested this link and it works fine. Now the problem is that after starting the camera I use the following code to capture an image:
bool CCamera::CaptureImage(LPCSTR i_lpszBMPFileName)
{
if (m_hWnd &&
capGrabFrameNoStop(m_hWnd) &&
capFileSaveDIB(m_hWnd, i_lpszBMPFileName))
return true;
return false;
}The m_hWnd is created with this code:
m_hWnd = capCreateCaptureWindow(m_sName, WS_CHILD|WS_CLIPSIBLINGS, 0, 0, 160, 120, i_hwndParnt, 0xffff);
i_hwndParent in both cases (before separating the application and after it) is obtained with the following code:
i_hwndParent = CreateWindow("STATIC", "parent", WS_POPUP, 0, 0, 20, 10, NULL, NULL, NULL, NULL);
Before changing the method to a client/server method, in CaptureImage everything was working fine. Both capxxx macros did their job and returned with true or false. But now, the program control remains inside them and the if statement is not evaluated until I stop the camera. After stopping the camera these macros return with true. It causes the application to remain in the CaptureImage function and never returns until the camera is stopped. I wondered what might be different in two methods. I couldn't realize why the macros don't return. Any idea? Thx