How to connect my esp32 cam to Matlab gui and stream video

70 ビュー (過去 30 日間)
Anas
Anas 2023 年 2 月 11 日
編集済み: Shiven Naidoo 2024 年 5 月 18 日
How to connect my esp32 cam to Matlab gui and stream video, I have the IP address but the problem is that it doesn't have the /cam.mjpeg after it and I keep getting an error
  1 件のコメント
Shiven Naidoo
Shiven Naidoo 2024 年 5 月 18 日
編集済み: Shiven Naidoo 2024 年 5 月 18 日
it's okay. I figured it out. I was able to stream the video on matlab.

サインインしてコメントする。

回答 (2 件)

Guillaume Baptist
Guillaume Baptist 2023 年 5 月 31 日
To get the stream video from matlab, I have installed the MATLAB Support Package for IP Cameras.
On the esp32-CAM side, I have uploaded the example arduino sketch called CameraWebServer.ino . This provides me with an IP adress to get the stream in my browser i.e i got the following message in the serial monitor: "Camera Ready! Use 'http://192.168.1.24' to connect"
Copy/pasting this adress in my browser (chrome) allows me to get a beautiful user interface to change differents parameters and it works well. Now, the problem in matlab is that just running the following line doesn't work :
cam = ipcam('http://192.168.1.24') ; % DOES NOT WORK FOR ME
It generates the following error.
Cannot connect to the IP Camera Stream URL. Make sure the URL is correct and authentication is provided if needed.
There is 2 main points to solve this problem:
  • one needs to use port 81 and not 80 which is the streaming port
  • one has to add "stream" at the end of the command
cam = ipcam('http://192.168.1.24:81/stream'); % WORK FOR ME
Then, it works for me and I get my cam object created and i can see the preview by doing:
preview(cam)
I also could get a snapshot with the following code:
clear all;
cam = ipcam('http://192.168.1.24:81/stream');
img = snapshot(cam);
imshow(img)
And I get my picture!
Hope it helps!
Cheers.
  2 件のコメント
Jonathan Gadiel Ramírez Martínez
Jonathan Gadiel Ramírez Martínez 2023 年 6 月 17 日
Guillaume, you are the man!!! This worked for me, thanks a lot!
Simphiwe Lindiwe
Simphiwe Lindiwe 2023 年 10 月 20 日
thank you so much

サインインしてコメントする。


Harshit Saini
Harshit Saini 2023 年 2 月 15 日
To connect your ESP32 Cam to MATLAB GUI and stream video, you can use the “ipcam” function available in the Image Acquisition Toolbox. Here are the steps you can follow:
  • In MATLAB, create a new script and execute the following lines of code:
vid = ipcam('http://IP_ADDRESS:PORT_NUMBER');
preview(vid);
% Replace IP_ADDRESS and PORT_NUMBER with the actual IP address and port number of your ESP32 Cam. Make sure that your ESP32 Cam is connected to the same network as your computer running MATLAB.
  • Run the script. The “ipcam” function should connect to the ESP32 Cam and start streaming the video.
If you are getting an error because the IP address doesn't have the /cam.mjpeg after it, try adding that to the end of the IP address in the “ipcam” function. For example:
vid = ipcam('http://IP_ADDRESS:PORT_NUMBER/cam.mjpeg');
This should allow MATLAB to correctly connect to the ESP32 Cam and stream the video
  2 件のコメント
Anas
Anas 2023 年 2 月 17 日
Still getting the same problem that it cannot connect to the IP camera stream URL
MathWorks MATLAB Hardware Team
MathWorks MATLAB Hardware Team 2023 年 3 月 8 日
Hi Anas, Could you post the exact error message that you are getting here.
Also an IP camera connection issue mentioned here is now fixed in the latest MATLAB update. Update your MATLAB and IP camera support package to the latest versions and try out the fix, to see if it resolves the issue.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Support Package for IP Cameras についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by