Home > other >  The python language using openCV cv2. CvtColor error
The python language using openCV cv2. CvtColor error

Time:11-30

Python language using openCV cv2 cvtColor error, where is wrong?

CodePudding user response:

That's because the frame is not 3 channel or 4 channel
 
If len (frame shape)==3 or len (frame) shape)==4:
Gray=cv2. CvtColor (frame, cv2 COLOR_BGR2GRAY
The else:
Gray=frame

CodePudding user response:

reference 1st floor corfox_liu response:
that's because the frame is not 3 channel or 4 channel
 
If len (frame shape)==3 or len (frame) shape)==4:
Gray=cv2. CvtColor (frame, cv2 COLOR_BGR2GRAY
The else:
Gray=frame

Hello, you said the three channels and four is what mean? This aspect to introduce online very few, can simple said it to me?

CodePudding user response:

refer to the second floor xianying7509 response:
Quote: refer to 1st floor corfox_liu response:

That's because the frame is not 3 channel or 4 channel
 
If len (frame shape)==3 or len (frame) shape)==4:
Gray=cv2. CvtColor (frame, cv2 COLOR_BGR2GRAY
The else:
Gray=frame

Hello, you said the three channels and four is what mean? This aspect to introduce online very few, can simple said it to me?

Is the color model, R (red), G (green) B (blue) the combination of red, green and blue three colors, synthesis of other colors, three-channel RGB, then there is a transparency
A (alpha), RGBA is four-channel, gray image is A single channel, OpenCV image Mat in each channel is A 8 bit, in order of BGR, so cvtColor transformation parameters are typically COLOR_BGR2GRAY,
Probably is the case, I know is not too detailed, for reference only, you can also check the OpenCV reference manual (docs.opencv.org), Google the color model and relevant knowledge.

CodePudding user response:

reference corfox_liu reply: 3/f
Quote: refer to the second floor xianying7509 response:

Quote: refer to 1st floor corfox_liu response:

That's because the frame is not 3 channel or 4 channel
 
If len (frame shape)==3 or len (frame) shape)==4:
Gray=cv2. CvtColor (frame, cv2 COLOR_BGR2GRAY
The else:
Gray=frame

Hello, you said the three channels and four is what mean? This aspect to introduce online very few, can simple said it to me?

Is the color model, R (red), G (green) B (blue) the combination of red, green and blue three colors, synthesis of other colors, three-channel RGB, then there is a transparency
A (alpha), RGBA is four-channel, gray image is A single channel, OpenCV image Mat in each channel is A 8 bit, in order of BGR, so cvtColor transformation parameters are typically COLOR_BGR2GRAY,
Probably is the case, I know is not too detailed, for reference only, you can also check the OpenCV reference manual (docs.opencv.org), Google color model and other related knowledge,


Hello, modify the code prompt: as you said AttributeError: 'NoneType' object has no attribute 'shape'

CodePudding user response:

The same mistakes,

CodePudding user response:

I also like this, it is an actress

CodePudding user response:

Ret, frame=CAM. The read ()
Here behind must be combined with judge whether the video read over judgment, or play to when the last frame to
If ret==False:
Break
Then re-run, is ok

CodePudding user response:

references 9/f, alpha's reply:
ret, frame=CAM. The read ()
Here behind must be combined with judge whether the video read over judgment, or play to when the last frame to
If ret==False:
Break
Then re-run, can the
by the way, is too good

CodePudding user response:

references 9/f, alpha's reply:
ret, frame=CAM. The read ()
Here behind must be combined with judge whether the video read over judgment, or play to when the last frame to
If ret==False:
Break
Then re-run, can the


thank you
  • Related