Webcam cannot be initialized properly.

7 visualizzazioni (ultimi 30 giorni)
chen
chen il 5 Gen 2025
Commentato: chen il 6 Gen 2025
Hello guys,
I would like to use a machine vision camera (usb3.0 cable) to connect the raspberry 4B for a machine vision projects with simulink, the machine vision camera has its own SDK, which has been done in the raspberry pi. Then, I used the v4l2loopback to create a virtual webcam into the point-/dev/video0. After all, I tested it use the command- "r=raspi; w=webcam(r)" to test the connection between the machine vision camera on raspberry pi and matlab, but I got an error at below:
r=raspi
r =
raspi with properties:
DeviceAddress: '192.168.137.208'
Port: 18734
BoardName: 'Raspberry Pi 2 Model B'
AvailableLEDs: {'led0'}
AvailableDigitalPins: [4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
AvailableSPIChannels: {'CE0','CE1'}
AvailableI2CBuses: {'i2c-1'}
AvailableWebcams: {'HT VirtualCam (platform:v4l2loopback-000)'}
I2CBusSpeed: 100000
AvailableCANInterfaces: {}
Supported peripherals
>> w=webcam(r)
Webcam cannot be initialized properly. Please check if the device HT VirtualCam (platform:v4l2loopback-000) is available and free to use.
Could someone can help me about how to make a non-stardard USB camera to be detected by matlab?
Thank you very much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Risposta accettata

Gayathri
Gayathri il 6 Gen 2025
Hi @chen,
From the error it seems like the camera is being used in some process and hence it was not able to create a connection in MATLAB.
To check if any of the process is using the webcam (outside the MATLAB), please follow the below steps.
  • Please check if any application is using the webcam by using "$ top" command in the pi terminal window.
  • Please check if any of the cron scheduler is using the webcam, by executing "$ crontab -e" and see if there are custom shell scripts or an application is running in timely basis.
  • If none of the above steps doesnot work we can reboot the Rasberry Pi using "$ sudo reboot" and confirm "$ fswebcam" works in the pi terminal and then go to MATLAB to create the webcam object.
  • If rebooting doesnot help, please follow the hardware setup process in MATLAB-> Addons-> Manage Addons->click on gear icon in Raspberry Pi support package and follow the setup process.
I hope this will resolve the issue! If you encounter any further problems, please feel free to reach out.
  3 Commenti
Gayathri
Gayathri il 6 Gen 2025
Did you try following the last step
  • If rebooting doesnot help, please follow the hardware setup process in MATLAB-> Addons-> Manage Addons->click on gear icon in Raspberry Pi support package and follow the setup process.
Did this not work?
Also, try reinstalling the image on Raspberry Pi by choosing "Setup hardware with MathWorks Raspbian image" after executing following command in MATLAB.
w = matlab.hwmgr.internal.hwsetup.register.RaspberryPiWorkflow;
w.launch
chen
chen il 6 Gen 2025
Hi, @Gayathri. I use the matlab customized iamge for raspberry 4B(matlab-2021b), and I have tried the last step, but it did not work. But I have tried a standrad UVC camera of logitech, it works fine. Thank you very much!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Raspberry Pi Hardware in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by