How to connect my esp32 cam to Matlab gui and stream video
40 次查看(过去 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
1 个评论
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
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!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1399744/image.jpeg)
Hope it helps!
Cheers.
2 个评论
Jonathan Gadiel Ramírez Martínez
2023-6-17
Guillaume, you are the man!!! This worked for me, thanks a lot!
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 个评论
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 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!