"Terminate the existing connection" for Raspberry Pi webcam despite not existing

3 ビュー (過去 30 日間)
Javi
Javi 2025 年 7 月 3 日
回答済み: sudobash 2025 年 7 月 7 日
Hi,
I'm trying to connect a Raspberry Pi and its HQ camera with MATLAB, through the Hardware Support Package. The installation was successful and I was able to contact the board and generate an r object with raspi().
r =
raspi with properties:
DeviceAddress: '192.168.1.45'
Port: 18734
BoardName: 'Raspberry Pi 4 Model B'
AvailableLEDs: {'ACT'}
AvailableDigitalPins: [4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
AvailableSPIChannels: {}
AvailableI2CBuses: {'i2c-0','i2c-1'}
AvailableWebcams: {'unicam (platform:fe801000.csi)'}
I2CBusSpeed: 100000
AvailableCANInterfaces: {}
As you can see, a webcam is detected right off the bat. When I try to access the webcam with a variable
w = webcam(r)
I get the following error message.
unicam (platform:fe801000.csi) is in use. You need to terminate the existing connection first
by clearing the webcam object.
I suspect it's because the availableWebcams field but I can't terminate the connection because my workspace is free of variables and I can't delete the contents of the field because it's read only. There is absolutely no information online about this situation and I would like to ask for some guidance.
Thanks.

回答 (1 件)

sudobash
sudobash 2025 年 7 月 7 日
Hi Javi,
There may be several reasons for why this may happen:
  • It may be possible that another persistent variable is holding onto the webcam resource. Type the following commands to clear all the variables and the current webcam variable:
clear all
clear w
  • There may be multiple instances of MATLAB running and one of the other instances has an active connection to the webcam. Close all running instances of MATLAB and try again.
  • There is also the possibility that another program running on the Raspberry Pi is using the webcam. Run the following command on the Raspberry Pi's terminal and kill any process that may show up:
lsof /dev/video0
Hope this helps!

カテゴリ

Help Center および File ExchangeRaspberry Pi Hardware についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by