cvtcolor in cv2 - no attribute

  • Last Update :
  • Techknowledgy :

Lastly, although the averaging works fine, is there a more elegant way to do it? I need a simple mean not a weighted average.

import os, numpy, PIL
from PIL
import Image
import cv2
import time
frameaverage = 5

def average_image():

   arr = numpy.zeros((h, w, 3), numpy.float)
# Build up average pixel intensities as floating
for im in xrange(frameaverage):
   camera_capture = get_image()
imarr = numpy.array(camera_capture, dtype = numpy.float)
arr = arr + imarr / frameaverage
# Round values convert to 8 - bit integer
arr = numpy.array(numpy.round(arr), dtype = numpy.uint8)
ave_image = Image.fromarray(arr, mode = "RGB")
RgbImage = cv2.cvtcolor(ave_image, cv2.COLOR_BGR2RGB)
return RgbImage

Suggestion : 2

When I run the code to the line above,the AttributeError occur.I have checked the package of cv2,but I don't find the module "cvtColor".But according to the introduction of cv2,it contains the module "cvtColor".I want to know what I can do to solve the problem.Thank you for your instruction,@LeiChangxin make sure you have used cvtColor not cvtcolor .,Hoping that you have correctly installed opencv-python. This error should not occur, as far as "image" is an RGB Image. I tried it with an RBG Image and the following OpenCV package. If not needed you can uninstall opencv-contrib and reinstall opencv-python with pip install opencv-python==4.5.1.48

Name: opencv - python
Version: 4.5 .1 .48
Summary: Wrapper package
for OpenCV python bindings.
Home - page: https: //github.com/skvark/opencv-python
   Author: None
Author - email: None
License: MIT
Location: /usr/local / lib / python3 .8 / dist - packages
Requires: numpy
Required - by:

Suggestion : 3

I never used python and openCV before and I anycodings_opencv-python don't know what is the problem.,the code with the error, sorry for the anycodings_opencv-python language translate from italian,this is the code, can somebody help me anycodings_opencv-python understand the problem?,should be cvtColor as cvtcolor renamed anycodings_opencv-python to cvtColor

I never used python and openCV before and I anycodings_opencv-python don't know what is the problem.

from PIL
import ImageGrab
import cv2
import time

last_time = time.time()
while (True):
   screen = np.array(ImageGrab.grab(bbox = (0, 40, 640, 480)))
print('Loop took {} second'.format(time.time() - last_time))
cv2.imshow('window', cv2.cvtcolor(screen, cv2.COLOR_BRG2RGB))
if cv2.waitKey(25) & 0xFF == ord('q'):
   cv2.destroyAllWindow()
break