问题描述
我正在尝试从 IP 摄像机获取并显示视频流.我在这里找到了一些示例代码:http://answers.opencv.org/question/24012/reading-video-stream-from-ip-camera-in-opencv-java/
I am trying to get and display an video stream from a IP camera. I found some sample code here:http://answers.opencv.org/question/24012/reading-video-stream-from-ip-camera-in-opencv-java/
但这对我不起作用.我的代码在我使用内部网络摄像头时有效,但是当我将摄像头切换到 IP 时,它不起作用.我不知道为什么.有人可以帮帮我吗?这是我的代码:
But it is not working for me. my code works when I use my internal webcam, but when I switch the camera to the IP, it does not work. I have no idea why. Can someone please help me? Here is my code:
感谢您的帮助.我能够使用您所说的找到正确的 IP 地址 (http://192.168.0.6/VIDEO.CGI)
(是的,我知道 7 变成了 6,它是不同的相机)在我的浏览器中获取视频.但我仍然收到以下错误.
Thank you for the help. I was able to use what you said to find the proper IP address (http://192.168.0.6/VIDEO.CGI)
(yes, I know the 7 became a 6, its a different camera) to get a video in my browser. but I am still get the following error.
我认为这是因为 VideoCapture 没有正确抓取帧.
I think it is because VideoCapture is not grabbing the frame correctly.
这是我正在尝试使用的相机http://www.trendnet.com/products/proddetail.asp?prod=150_TV-IP100W-N
This is the camera I am trying to use http://www.trendnet.com/products/proddetail.asp?prod=150_TV-IP100W-N
推荐答案
.jpg 指的是单个图像文件,而 .mjpg 则可以访问视频流.定义用于连接的 IP 和 PORT 很重要.
.jpg refers to a single image file, while .mjpg gives access to the video stream. It's important to define the IP and the PORT used to connect.
根据您拥有的设备和相机网络界面中定义的设置,URL 会有所不同:
Depending on the device you have and the settings defined in the web interface of the camera, the URL is going to be different:
当您通过浏览器访问有效 URL 时,它应该显示视频流.找到有效的地址后,只需将其传递给 VideoCapture
构造函数.在这个示例中,我展示了如何通过 HTTP 访问流,但也支持 RTSP 协议.
When you access a valid URL via browser it should display the video stream. Once you find the address that works, simply pass it to VideoCapture
constructor. In this examples I showed how to access the stream via HTTP, but the RTSP protocol is also supported.
这篇关于Java中带有OpenCv的IP摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!