Error using C++ code to access camera via mex.

조회 수: 4 (최근 30일)
Cosmin Constantin Popescu
Cosmin Constantin Popescu 2022년 7월 28일
댓글: Gabriel Seymour 2023년 7월 18일
I am trying to get an image from a thorlab camera via matlab. I am using a code from github ( https://github.com/mdaddysman/Thorlabs-CMOS-USB-cameras-in-Matlab ) where I add the .h and .lib files needed and run it. I have run succesfully this code on my laptop on 2021a. On a different computer, I had 2020b and then (in the process of troubleshooting this), I updated to 2021b. In neither version, I can get the image reliably on the second computer.
To be specific, after I run the installation file provided to make the mex files from c++, or after I open MATLAB, I have a short window of time during which I can run the video function provided from github before it throws out one of two errors: "Failed to 1 FreezeVideo: r = 178" or "Failed to 2 FreezeVideo: r = 178". To clarify, I do get a live image but only for several seconds before it stops and throws out this error, which makes me think that something is running in the background generating some change and interfering with the code.
I tracked this to a c++ file which looks if the video is frozen. The code that throws the error seems to be in the mex originating from the cpp GetImage.cpp:
result = is_FreezeVideo(phCam,IS_WAIT);
if(result != IS_SUCCESS)
{
is_FreeImageMem(phCam,pImage,imgID);
mxFree(pImage);
is_ExitCamera(phCam);
sprintf(errbuffer,"Failed to 1 FreezeVideo: r = %i",result);
mexErrMsgTxt(errbuffer);
return;
}
and this occurs in the matlab side when I try to get an image with
image = GetImage(hCam,width,height);
The first thing I am trying to understand is why does it take some time between when the image collection is still viable and when the error is thrown.
Please, let me know if anyone has any advice on what may be creating this, how to debug it and get it operational on a different machine.
  댓글 수: 1
Gabriel Seymour
Gabriel Seymour 2023년 7월 18일
Hello, please see my response to the open issue on the Github repo found here https://github.com/mdaddysman/Thorlabs-CMOS-USB-cameras-in-Matlab/issues/1. Fortunately, this is a simple fix and the code in the pull request should be ready to download and use.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for IP Cameras에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by