Hi, I’ve got a small camera from which I stream mjpeg video. I’d like to capture this for further processing in my android app. I have a runnable class MJpegCapture which has this “run” function:
public void run(){
s = new Size();
frame = new Mat();
toRun = true;
VideoCapture capture = new VideoCapture();
capture.open(mJPEGUrl);
capture.read(frame);
s.height = frame.rows();
s.width = frame.cols();
while (capture.read(frame) && toRun == true) {
listener.onFrameReceived(frame);
frame.release();
System.gc();
}
capture.release();
}
When using this in a java project on a desktop, it seems to work, but on android I get this error:
2021-05-28 09:06:17.366 6915-6915/com.example.myapp E/NativeCodec: failed to stat file: http://172.16.0.193:8000?dummy=param.mjpg (No such file or directory)
What I did to resolve this issue:
1.) I made sure that the url is actually accessible by accessing ti with the browser of the device I use for testing. Video streaming on the url works.
2.) I made sure that Internet Permissions have been granted in the manifest.
<uses-permission android:name="android.permission.INTERNET" />
3.) I made sure cleartext traffic is allowed
android:usesCleartextTraffic="true"
4.) I added “?dummy=param.mjpg” to the end of the url as some users of the internet seem to believe it is necessary.
I’m not sure how to proceed. Does anyone have a hint or an alternative approach?