0

I have a little project that should read VideosStream from rtsp camera to do some other tasks. I could run its original hc_yolo_all.py file without any issue. However, after making an executable file with pyinstaller --onefile hc_yolo_all.py, it couldn't derive VideoStream and gave the error

 Traceback (most recent call last):
  File "hc_yolo_all.py", line 60, in <module>
cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp:4044: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

[7340] Failed to execute script hc_yolo_all. 

It is seen that frame = cv2.resize(frame, (416,416)), line 60, of hc_yolo_all.py is receiving an empty frame and therefore, output an error.

Where do you think the issue lies in?

I, to be honest, don't know whether it is related to opencv or rtsp or pyinstaller, so I've tagged those three.

bit_scientist
  • 1,496
  • 2
  • 15
  • 34
  • You might just implement a simple if statement that applies cv2.resize only if received frame is not empty? This way you would be able to get all the rtsp VideoStream ignoring the empty incoming frames – Employee Nov 14 '18 at 09:25
  • @Employee, good point, but I mentioned I could run a program without any issue when I directly used .py file itself. Otherwise I wouldn't be able to do that. I tend to think that **.exe** file can't get access to the provided **rtsp** address – bit_scientist Nov 15 '18 at 04:49

1 Answers1

0

Well, I could find a solution to my own question. It looks like we need to have a opencv_ffmpegxx.dll alongside with the .exe file. Here, xx should be the version of opencv when the .py was being made .exe. My opencv version was 3.4.3 (even Error is showing above), therefore, I put opencv_ffmpeg343_64.dll next to my .exe.

How to find corresponding dll: Look for the C:\Users\username\Anaconda3\envs\envname\Lib\site-packages\cv2/ in case of using Anaconda.

Credits to this

bit_scientist
  • 1,496
  • 2
  • 15
  • 34