Coder Social home page Coder Social logo

OpenCV(3.4.3) /io/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' about video2tfrecord HOT 7 CLOSED

ferreirafabio avatar ferreirafabio commented on June 5, 2024 1
OpenCV(3.4.3) /io/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

from video2tfrecord.

Comments (7)

danielbraun89 avatar danielbraun89 commented on June 5, 2024

I have the same error:

cv2.error("OpenCV(3.4.4) C:\\projects\\opencv-python\\opencv\\modules\\imgproc\\src\\color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'\n")

from video2tfrecord.

danielbraun89 avatar danielbraun89 commented on June 5, 2024

The program crashes even after installing the exact opencv version specified in the requirements.txt file (opencv-python==3.4.0.12),

the error code however, changed to:

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor, file C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp, line 11079

from video2tfrecord.

fascinet avatar fascinet commented on June 5, 2024

@ferreirafabio Have you any idea how to resolve this error or any other way for the conversion?

from video2tfrecord.

danielbraun89 avatar danielbraun89 commented on June 5, 2024

I went ahead and debugged the code, here are my conclusions:

video2tfrecord.py:291

frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
No check is being done on whether the frame is None.
This is causing the original crash

video2tfrecord.py:294

stop, cap, steps, prev_frame_none, frames_counter = repeat_image_retrieval( cap, file_path, take_all_frames, steps, frame, prev_frame_none, frames_counter)

This was probably written for older opencv signature, the new one require the video as a parameter, (and henceforth returns tuple of size 6 and not 5)

No break check or frames_counter increase at

video2tfrecord.py: 301

Causing an infinite loop...

video2tfrecord.py: 294

Using the frame_counter name as unpack variable is overriding the internal counter and again causing an infinite loop...

video2tfrecord.py: 294

Using the cap name as unpack variable and overriding the original cap.
If the cap is being set to None the program again crashes at

video2tfrecord.py: 338

This may be a bug, and maybe not. Im not sure what is the appropriate behavior but in

video2tfrecord.py: 301

It seems video[frames_counter, :, :, :].fill(0) would be more logical than to erase the whole video.

@fascinet I have pushed this changes into a fork: https://github.com/danielbraun89/video2tfrecord

for a quick fix you can just use your own pip installed version and copy the content of https://github.com/danielbraun89/video2tfrecord/blob/master/video2tfrecord.py
into the video2tfrecord.py file that is being used in your installed package.

also I have tested it in the latest opencv, I recommend running a
pip install opencv-python -U
and disregard the requirements.txt opencv version until the official fix will arrive

from video2tfrecord.

fascinet avatar fascinet commented on June 5, 2024

Thank you for your reply. It worked very well BTW Great Observation.

from video2tfrecord.

ferreirafabio avatar ferreirafabio commented on June 5, 2024

Thank you for these findings and for reporting them. Would you be interested in creating a pull request such that all users would benefit from your bugfixes? I unfortunately don't have time to incorporate these in the next weeks/months. I also don't have time to check whether these reported findings are actually bugs

from video2tfrecord.

ferreirafabio avatar ferreirafabio commented on June 5, 2024

Thank you all for your support. The suggestion have now been merged into the master.

from video2tfrecord.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.