i3drobotics / stereo-vision-toolkit

Stereo image processing suite
MIT License
30 stars 10 forks source link

TIS camera can cause crash if left in unsafe state #46

Closed ghost closed 4 years ago

ghost commented 4 years ago

If a TIS camera is manually removed from the computer while the program is running, this can leave the camera in an unsafe state. When the camera is connected the TIS library is unable to recognise the camera is in this state and continues as normal however is unable to capture images. The program does not immediately crash, however, if they try to disconnect the camera (using the GUI) then as the camera is not properly connected, this causes a crash.

CameraImagingSource::open returns with success as both 'handle.openDev()' and 'handle.isDevValid()' return with success even if the camera is in an unsafe state and unable to capture images.

cameraimaginsource.cpp

bool CameraImagingSource::open(std::string serial){
    qint64 qSerial = QString::fromStdString(serial).toInt();
    this->serial = qSerial;
    handle.closeDev();
    bool res = handle.openDev(qSerial);

    if (!handle.isDevValid()) {
      debugMessage("Couldn't open camera");
      QMessageBox alert;
      alert.setText(QString("Couldn't open camera with serial %1.").arg(qSerial));
      alert.exec();
    }else{
        this->width = handle.getVideoFormat().getSize().cx;
        this->height = handle.getVideoFormat().getSize().cy;

        debugMessage("Opened camera");
    }

    return res;
}