Giter VIP home page Giter VIP logo

Comments (23)

shravankumar9892 avatar shravankumar9892 commented on July 17, 2024 95

Even I had the same problem, and the solution was quiet easy. Remember 1 thing, if the RGB values of your image lie in the range of 0-255, make sure the values are not of data type 'float'. As OpenCV considers float only when values range from 0-1. If it finds a float value larger than 1 it clips off the value thinking floats only exsist between 0-1. Hence such errors generated. So convert the data type to uint8 if values are from 0-255.
image = image.astype('uint8')
Check this Kaggle Kernal

from object_detection_demo_live.

hollowstrawberry avatar hollowstrawberry commented on July 17, 2024 63

I'm pretty sure it just means the image doesn't exist. I fixed the path when opening the image and it worked for me.

from object_detection_demo_live.

Sannndy0000 avatar Sannndy0000 commented on July 17, 2024 21

I met the same problem and found that this occurred to me simply because I commented out 2 lines:

if cv2.waitKey(1) & 0xFF == ord('q'):
        break

Getting them back made it work.

from object_detection_demo_live.

pblxptr avatar pblxptr commented on July 17, 2024 19

I have the same issue, but fixing the path does not work for me.

from object_detection_demo_live.

pblxptr avatar pblxptr commented on July 17, 2024 7

The image isn't None. I can show it. It occurs when I'm trying to convert image from RGBA to GRAY.

from object_detection_demo_live.

hollowstrawberry avatar hollowstrawberry commented on July 17, 2024 6

When I next got this error (or a very similar one at least) it was because I was trying to make my own image with a numpy array. It probably doesn't help in your cases, but I realized each pixel has to be on its own sublist, like so: [[[a,b,c]], [[a,b,c]], [[a,b,c]]]

Try printing your image to the console to see if it makes sense

from object_detection_demo_live.

shubhambagwari avatar shubhambagwari commented on July 17, 2024 6

Try this once,
cap = cv2.VideoCapture(0) #O is for internal camera.
cap = cv2.VideoCapture(1) #1 is for external camera.

from object_detection_demo_live.

hollowstrawberry avatar hollowstrawberry commented on July 17, 2024 5

Due to the cause of the error in my case, you might want to double check that the image isn't None, or in an otherwise invalid state I suppose (though about that I wouldn't know)

from object_detection_demo_live.

JH-Xie avatar JH-Xie commented on July 17, 2024 2

I solved this problem by use x = np.asarray(x, dtype=np.uint8) before do the conversion

from object_detection_demo_live.

INF800 avatar INF800 commented on July 17, 2024 1

I solved this problem by use x = np.asarray(x, dtype=np.uint8) before do the conversion

for this code, i used your instruction :

cap = cv2.VideoCapture(0)

while(True):
# Capture frame-by-frame
ret, frame = cap.read()

frame = np.asarray(frame, dtype=np.uint8)


# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
    break

When everything done, release the capture

cap.release()
cv2.destroyAllWindows()

i am getting error : int() argument must be a string, a bytes-like object or a number, not 'NoneType'

from object_detection_demo_live.

Faguilar-V avatar Faguilar-V commented on July 17, 2024 1

I have the same issue, but fixing the path does not work for me.

Yes, only change the path work

from object_detection_demo_live.

xaggi avatar xaggi commented on July 17, 2024

Hi, did you solve it? I am having the same issue here :(

from object_detection_demo_live.

ArmoredReaper avatar ArmoredReaper commented on July 17, 2024

I'm getting the same error, even when using the full path to the image. Someone else I know had the same problem and fixed it by moving the pictures, but I can't get it to work no matter what I try. (FYI working on a Mac, not sure if that changes anything)

from object_detection_demo_live.

Hitsaa avatar Hitsaa commented on July 17, 2024

I also had the same issue. Actually I had mistakenly typed wrong name of image file in my code that I was trying to import. But when I typed the right name of file then this issue was solved.

from object_detection_demo_live.

Soumyatrivedi3099 avatar Soumyatrivedi3099 commented on July 17, 2024

error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper'
i have this same error and i dont know how to remove it.

from object_detection_demo_live.

ZP-Guo avatar ZP-Guo commented on July 17, 2024

I get this error because of a stupid bug. I use LSP dataset to train some nets recently and this bug that you discuss comes. What something wrong. I find it for two days. And I find "im00001.jpg" was changed into "img00001.jpg" by myself.
So maybe it is just a little bug that I can not get it as soon as I can.

from object_detection_demo_live.

Mahdidrm avatar Mahdidrm commented on July 17, 2024

Try this once,
cap = cv2.VideoCapture(0) #O is for internal camera.
cap = cv2.VideoCapture(1) #1 is for external camera.

Yeeees... thank you ! I am working on a code that wrote on labtop and I am running it on my PC... I use 1 and it works !!!! thanks a lot

from object_detection_demo_live.

Dhurub007 avatar Dhurub007 commented on July 17, 2024

get the same error while using trackbar in opencv but after this method it resolved
img = np.full((512,512,3), 12, np.uint8)

from object_detection_demo_live.

SCF-byter avatar SCF-byter commented on July 17, 2024

I had exactly the same error.
Basically, it happend because I accidentally put Greyscale images into cv2.cvtColor(image, cv2.COLOR_BGR2RGB). So make sure you are definitively putting in color images (i.e. images with three channels)

from object_detection_demo_live.

14-purva avatar 14-purva commented on July 17, 2024

error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'cv::CvtHelper<struct cv::Set<3,4,-1>,struct cv::Set<1,-1,-1>,struct cv::Set<0,2,5>,2>::CvtHelper'
can somebody help me out with this error....

from object_detection_demo_live.

Zaniyar avatar Zaniyar commented on July 17, 2024

Non of the above solved my problem.

What I noticed is, when I use pyCharm or Code I get those errors.
In pyCharm:

  rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA)
cv2.error: OpenCV(3.4.2) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.hpp:253: error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper'

in Code:
Abort trap: 6

I tested: I have everywhere the same env and same python version.

Solution for me:

When I run the code in the standalone terminal, it works fine.

I tried also to run Code as admin (with sudo on the terminal, but got same errors).

from object_detection_demo_live.

Michal2207 avatar Michal2207 commented on July 17, 2024

I've got the same error. I fixed it by using two '\' in the file path instead of one ''.

from object_detection_demo_live.

rafaelmsales27 avatar rafaelmsales27 commented on July 17, 2024

I had the same problem, I was sure the path was right.

My problem was in the cv2.imread I had before the color conversion.

Since I am getting the image from a file instead of cv2.VideoCapture.

My code was as follows:

# x is my path
for x in list_of_paths:
        raw_img = cv2.imread(x)
        raw_img_colored = cv2.cvtColor(raw_img, COLOR_BayerRG2RGB)

The solution was to put the cv2.IMREAD_UNCHANGED (or -1) inside the cv2.imread method as follows:

# x is my path
for x in list_of_paths:
        raw_img = cv2.imread(x, -1)
        raw_img_colored = cv2.cvtColor(raw_img, COLOR_BayerRG2RGB)

Hope it helps!

from object_detection_demo_live.

Related Issues (9)

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.