Ask Your Question

arp's profile - activity

2020-03-16 10:08:07 -0600 received badge  Popular Question (source)
2014-09-29 16:47:56 -0600 commented question Is it normal for "new VideoCapture()" to take AGES?

P.S. I have by now measured that RTSP works significantly better than HTTP. Unfortunately, I cannot get RTSP to work via SSH tunnels.

I know that for "ffmpeg" (using which, as far as I know, OpenCV does its RTSP work) accepts the command line option "-rtsp_transport tcp", which makes it use TCP. Does anyone know, is there a way to specify this in OpenCV, especially when using the Java API?

2014-09-29 12:36:16 -0600 commented question How to convert from Iplimage to Mat in java?

Basically, I would try to read the "imageData" field from IplImage structure and write it using "matrix.put(0, 0, data);" to the Mat object. If the dimensions and color palettes already match before trying this, it might succeed. But I've got no working method to try, since I can't get any IplImage structures on my system...

2014-09-29 12:26:13 -0600 commented question How to convert from Iplimage to Mat in java?

This might not be of much help (just bits and pieces)... but someone posted the structure of IplImage here:

http://stackoverflow.com/questions/17307430/explanation-of-iplimage-img

...and a fast function to convert Mat into java.awt.image.BufferedImage (which might resemble IplImage to some degree), can be found here:

http://answers.opencv.org/question/10344/opencv-java-load-image-to-gui/

( look for "public static BufferedImage matToBufferedImage(Mat bgr)" )

2014-09-29 12:13:59 -0600 commented question capture image to slow with java

(sorry, initially posted as answer, now posting as comment, I'm a little new to this site)

Can you confirm which part of the code is slow? Is it opening the camera, or reading frames?

I'm asking because I have discovered that opening a connection to an IP camera in Java is horribly slow (have to wait a whole minute), but getting frames from the camera afterwards runs at reasonable speed.

2014-09-29 12:12:39 -0600 answered a question capture image to slow with java

Can you confirm which part of the code is slow? Is it opening the camera, or reading frames?

I'm asking because I have discovered that opening a connection to an IP camera in Java is horribly slow (have to wait a whole minute), but getting frames from the camera afterwards runs at reasonable speed.

2014-09-29 12:04:23 -0600 asked a question Is it normal for "new VideoCapture()" to take AGES?

I've built an inventory robot for a warehouse. It has two IP cameras (Vivotek CC8130). Its onboard computer is a FitPC, the operator console is a random Lenovo notebook. Both computers run OpenCV 2.4.9 on Debian GNU/Linux Jessie/sid. The onboard program and the operator console share the same codebase. They are written in Java 1.6.

In principle, everything works. I can open a video stream into the cameras from both computers. Both "http" and "rtsp" work. Once the stream is open, performance is reasonable....

...but what absolutely puzzles me: on both computers, it takes AGES (something like one minute per camera) to perform the following operation (both for RTSP and HTTP, but HTTP seems to take especially long):

logger.info("Attempting to open video capture for mast camera.");
vcMast = new VideoCapture("http://127.0.0.1:8001/video2.mjpg");
// VideoCapture vcMast = new VideoCapture("rtsp://127.0.0.1:5554/live2.sdp");

This occurs every time. It occurs when connecting directly and likewise when going through SSH tunnels (the sample code shows "127.0.0.1" for the camera IP, because it was copied during SSH testing). To provide a little context of what I'm doing:

// Import libraries.
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;
import org.opencv.highgui.VideoCapture;
/.../
public class ClientMain {
/.../
// Initialize OpenCV
static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
/.../
public VideoCapture vcMast = null;
public VideoCapture vcFloor = null;
/.../
logger.info("Welcome to OpenCV " + Core.VERSION);
/.../
try {
logger.info("Attempting to open video capture for mast camera.");
vcMast = new VideoCapture("http://127.0.0.1:8001/video2.mjpg");
// VideoCapture vcMast = new VideoCapture("rtsp://127.0.0.1:5554/live2.sdp");
/.../

....and here it hangs for a whole minute, before getting to:

if (vcMast.isOpened())

P.S. What I notice: when it finally gets unstuck, and I get to call "vcMast.read(frame)", where "frame" is an object of type "Mat"... I immediately get a bunch of past frames, as if they had been accumulating in a buffer somewhere. Once the buffer is spent, I start getting fresh frames.