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

70 次查看(过去 30 天)
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

回答(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.

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
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 CenterFile Exchange 中查找有关 MATLAB 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