How to connect SJCAM SJ4000 as a webcam to MATLAB

7 views (last 30 days)
Hi, I have just bought a SJCAM action camera, model SJ4000.
It is able to function as a normal webcam on the PC. Hence, I tried connecting it to MATLAB as a webcam so that I can acquire images through MATLAB for an image processing project, however, the following error showed up:
P.S.: I have installed the MATLAB Support Package for USB Webcams and have updated the SJ4000 camera to its latest firmware.
>> webcamlist
ans =
cell
'J1455 '
>> cam = webcam('J1455 ')
Warning: The following error was caught while executing
'matlab.webcam.internal.WebcamController' class destructor:
Struct contents reference from a non-struct array object.
Error in matlab.webcam.internal.WebcamController/delete
Error in matlab.webcam.internal.WebcamController
Error in webcam (line 159)
matlab.webcam.internal.WebcamController(devName, devID);
> In matlab.webcam.internal.WebcamController
In webcam (line 159)
Error. The format exposed by the webcam is not supported.
I have tried connecting other webcams (BisonCam, NB Pro and Logitech C170 webcam) to MATLAB and has managed to get them working, but not for this SJ4000 camera.
I would like to know what's the solution to this error, your help is much much appreciated!
  2 Comments
Grzegorz Wieczorek
Grzegorz Wieczorek on 24 Apr 2017
I managed it that way:
>> webcamlist
ans =
2×1 cell array
'Chicony USB 2.0 Camera'
'J1455 '
>> obj = videoinput('winvideo', 2);
>> obj.SelectedSourceName = 'input1';
>> obj = videoinput('winvideo', 2, 'MJPG_1920x1080');
>> preview(obj)
And it worked for me.
Pragnesh Gamit
Pragnesh Gamit on 4 Mar 2018
Edited: Pragnesh Gamit on 4 Mar 2018
how to take snapshot of the preview ?

Sign in to comment.

Answers (1)

Eugene Lipunov
Eugene Lipunov on 13 Dec 2022
imaqhwinfo
% choose the source by index vidid, get vid
vid = videoinput ('winvideo', vidid);
% optional: src = getselectedsource (vid);
preview (vid);
% loop to get snapshots (do not close preview)
img = getsnapshot (vid);

Community Treasure Hunt

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

Start Hunting!