opencv-android icon indicating copy to clipboard operation
opencv-android copied to clipboard

VideoCapture error: can't find starting number

Open sinabolouki opened this issue 2 years ago • 1 comments

I want to capture a video from a RTSP server using opencv on android. My implementation is like this:

if(!OpenCVLoader.initDebug()) {
    return
}

val cap = VideoCapture()
cap.open("rtsp://10.181.73.158:8086/?camera=world")

I'll get this error running last line:

2024-01-08 16:27:18.944 22957-23040 cv::error()             com.example.birthday                 E  OpenCV(4.5.2) Error: Requested object was not found (could not open directory: /data/app/~~eXkZfablwsElr9gDEsa36A==/com.example.birthday-f_lYz1toHNeSIJMnjZCcuA==/base.apk!/lib/arm64-v8a) in glob_rec, file /home/quickbirdstudios/opencv/opencv/modules/core/src/glob.cpp, line 267
2024-01-08 16:27:19.060 22957-23040 cv::error()             com.example.birthday                 E  OpenCV(4.5.2) Error: Requested object was not found (could not open directory: /data/app/~~eXkZfablwsElr9gDEsa36A==/com.example.birthday-f_lYz1toHNeSIJMnjZCcuA==/base.apk!/lib/arm64-v8a) in glob_rec, file /home/quickbirdstudios/opencv/opencv/modules/core/src/glob.cpp, line 267
2024-01-08 16:27:19.060 22957-23040 cv::error()             com.example.birthday                 E  OpenCV(4.5.2) Error: Requested object was not found (could not open directory: /data/app/~~eXkZfablwsElr9gDEsa36A==/com.example.birthday-f_lYz1toHNeSIJMnjZCcuA==/base.apk!/lib/arm64-v8a) in glob_rec, file /home/quickbirdstudios/opencv/opencv/modules/core/src/glob.cpp, line 267
2024-01-08 16:27:19.060 22957-23040 cv::error()             com.example.birthday                 E  OpenCV(4.5.2) Error: Requested object was not found (could not open directory: /data/app/~~eXkZfablwsElr9gDEsa36A==/com.example.birthday-f_lYz1toHNeSIJMnjZCcuA==/base.apk!/lib/arm64-v8a) in glob_rec, file /home/quickbirdstudios/opencv/opencv/modules/core/src/glob.cpp, line 267
2024-01-08 16:27:19.061 22957-23040 cv::error()             com.example.birthday                 E  OpenCV(4.5.2) Error: Bad argument (CAP_IMAGES: can't find starting number (in the name of file): rtsp://10.181.73.158:8086/?camera=world) in icvExtractPattern, file /home/quickbirdstudios/opencv/opencv/modules/videoio/src/cap_images.cpp, line 253
2024-01-08 16:27:19.061 22957-23040 OpenCV/4.5.2            com.example.birthday                 E  [ERROR:0] global /home/quickbirdstudios/opencv/opencv/modules/videoio/src/cap.cpp (162) open VIDEOIO(CV_IMAGES): raised OpenCV exception:
                                                                                                    
                                                                                                    OpenCV(4.5.2) /home/quickbirdstudios/opencv/opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): rtsp://10.181.73.158:8086/?camera=world in function 'icvExtractPattern'
2024-01-08 16:27:19.061 22957-23040 NativeCodec             com.example.birthday                 E  failed to stat file: rtsp://10.181.73.158:8086/?camera=world (No such file or directory)

I also had this error in python, but I could fix it by setting envrionment variable OPENCV_FFMPEG_CAPTURE_OPTIONS to rtsp_transport;0 so in python, my code was like this:

import os

os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;0"

cap = cv2.VideoCapture("rtsp://10.181.73.158:8086/?camera=world")

while cap.isOpened():
    ret, frame = cap.read()
    cv2.imshow('frame', frame)
    if cv2.waitKey(20) & 0xFF == ord('q'):
        break

However, setting envrionment variables in Android seems impossible. Are there any other way I can use to fix this issue?

sinabolouki avatar Jan 08 '24 15:01 sinabolouki

image image @sinabolouki There is no expectation of opencv library available to capture video using rtsp url , this made me write c++ and it didn't work , maybe openCV's rtsp doesn't work on android ? that's all i wonder

tienldbnk avatar Aug 04 '24 11:08 tienldbnk