I know there are many related questions 1, 2, etc but they didn't help me to read a frame. I have an IP camera that is connected to the Ethernet socket of my laptop with a Cat6 cable. and the camera is connected to the power supply as well. I want to read the camera using OpenCV. I surfed the internet to find out the solution but it seems (but not mentioned) that they use a router or internet to access the camera.
My camera is directly connected to the laptop and I want to store the frame to a Mat
. How can I do this? In addition, I read somewhere that camera's driver is a need. Here is the simplified version of my problem. If I use 0 instead of the URL it works. The URL is my problem. I can not access the URL using Web browser.
public static void main(String[] args) {
// load openCV libraries
nu.pattern.OpenCV.loadShared();
System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
VideoCapture cam = new VideoCapture ("rtsp://192.168.1.171/video.mpeg"); // I also tested some http URLs
Mat frame = new Mat();
if (cam.isOpened())
System.out.println("IP Camera is open");
cam.read(frame);
Imgcodecs.imwrite("IPCAM.jpg", frame);
System.out.println("finished");
}
Using Fedora, Java 9, Eclipse, maven