Hello again,
I've developed a dll to use some Flex:v100 cameras with VC++ 2005 and I have tested it with good results with an auxiliar aplication.
The problem i've got now is when I try to use it in a great aplication; everything runs good except the moment I try to stop the cameras. The aplication fails and I don't know why.
I've tried no stopping the cameras and closing them directly but that's not the solution. All the INPCamera objects are stored on a vector and when I try to clear it the aplication fails too.
It's very strange because calling the same methods in the same way on another aplication ther is no problem.
Could somebody help me? The code of the method that breaks:
/// Define an iterator to call the cameras
std::vector>::iterator m_iterCamera;
// std::vector::iterator m_iterCamera;
Logger->WriteMessageLog("Hemos definido el iterador");
/// Define an integer to know the state ot the camera
int c = 0;
/// Stop the adquisition for every camera
for(m_iterCamera=m_listCamera.begin(); m_iterCamera!=m_listCamera.end(); ){
Logger->WriteMessageLog("Para la camara",c);
(*m_iterCamera)->get_SerialNumber(&m_lSerial);
Logger->WriteMessageLog("Su serial",m_lSerial);
if(m_iCameraState[c]==CAMERA_STARTED){
Logger->WriteMessageLog("La camara esta STARTED");
/// First stop the capture
Logger->WriteMessageLog("La intentamos parar");
m_hExecutionResult = (*m_iterCamera)->Stop();
Logger->WriteMessageLog("La hemos parado");
if(m_hExecutionResult==S_OK){
this->Logger->WriteMessageLog(" La captura de imagenes esta detenida para la camara",m_lSerial);
m_iCameraState[c] = CAMERA_STOPPED;
}
else this->Logger->WriteMessageLog("ERROR: No se ha podido detener la captura para la camara",m_lSerial);
m_iCameraState[c] = CAMERA_STOPPED;
}
if(m_iCameraState[c] == CAMERA_STOPPED || m_iCameraState[c] == CAMERA_OPENED){
/// Close the camera
Logger->WriteMessageLog("La intentamos cerrar");
m_hExecutionResult = (*m_iterCamera)->Close();
Logger->WriteMessageLog("La hemos cerrado");
this->DispEventUnadvise((*m_iterCamera));
(*m_iterCamera) = NULL;
if(m_hExecutionResult==S_OK){
this->Logger->WriteMessageLog(" La camara esta cerrada",m_lSerial);
m_iCameraState[c] = CAMERA_CLOSED;
}
else this->Logger->WriteMessageLog("ERROR: No se ha podido cerrara la camara",m_lSerial);
}
else if(m_iCameraState[c] == CAMERA_CLOSED)
this->Logger->WriteMessageLog("ERROR: La camara ya esta cerrada",m_lSerial);
c++;
m_iterCamera++;
}
the object "logger" writes some information on a log file and m_listCamera is the vactor taht stores the INPCamera objects.
Thanks a lot,
Eduardo Valtuille
this->Logger->WriteMessageLog("Limpiamos la lista de las camaras");
m_listCamera.clear();
this->Logger->WriteMessageLog("Hemos limpiado la lista de las camaras");
this->Logger->WriteMessageLog("Limpiamos la lista de los seriales");
m_vCamerasSerial.clear();
this->Logger->WriteMessageLog("Hemos limpiado la lista de los seriales");
this->Logger->WriteMessageLog("Llamamos al CoUninitialize");
CoUninitialize();
this->Logger->WriteMessageLog("Hemos Llamado al CoUninitialize");
Problem stopping cameras
Re: Problem stopping cameras
Just looking at your code, it looks like it could work properly. It might be something less obvious, like making these calls from another thread from your main application thread while you're doing something else that conflicts in the main thread.