#๐Ÿ”’ Opencv is having an error every time I run

38 messages ยท Page 1 of 1 (latest)

worn sierraBOT
#

@rain sky

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

rain sky
#

I didn't realise it didnt like me adding python files

#

and this is the error^^^

#

line 98 if that helps

lucid abyss
rain sky
#

i think this is where the error is happening

lucid abyss
#

That's a function definition, I thought you pointed to the line where it errors

#

Anyway, your error says "Invalid number of channels in input image [...] where [...] is 1" So I'm guessing you gave a grayscale image to something that expects three channels

rain sky
#

yes

#

well its trying to turn an image into grayscale

#

like this one

lucid abyss
#

Can you find the actual line where it errors?

#

With a debugger, or with prints

rain sky
#

ok

#

its not in that funtion I thought it was in

#

its on line 130

lucid abyss
#

Line 130 is processed_images = preprocess_images(images), so it's inside the function you showed earlier

#

Find the line within that function that raises an error

rain sky
#

it is a slightly different one

#

its preprocess_images instead of preprocess_image

lucid abyss
#

oh, you have image and images, ok

rain sky
#

yeah

lucid abyss
#

ok, so what line within that function errors?

rain sky
#

74

vapid stirrup
#

(my guess is that img is already gray)

rain sky
#

I was just about to say

lucid abyss
#

ok, so now you go to line 74 and check the shape of img to confirm

#

And if that's the case, you should:

  1. Decide if it's acceptable that one of the images is already gray, and if so handle it.
  2. Or, if it shouldn't be gray, find out why it is
rain sky
#

I dont think I really need that function

#

as I want to let the image be as big as it wants

#

instead of resizing it to 256 pixels

lucid abyss
#

You also normalize the values in the image. You don't need that either?

#

There's also a thresholding there

worn sierraBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.