'PIRGBArray' from 'picamera.array'/// Help, please

I’m just studying, I’m working on raspberry pi4, I’m trying a lot with the camera operation. For some reason, it can only run through the use of picamera2, although picamera is also installed. There is clearly an error using a ‘non-existent’ method from the library, although everything seems to be in the documentation. Help, please

here’s the code:
import numpy as np
import cv2
from picamera2 import Picamera2
from picamera.array import PIRGBArray

cam = Picamera2()
cam.resolution = (640,480)
cam.framerate = 30
#raw_capture = PiRGBArray(cam, size = (640,480))
raw_capture = PIRGBArray(cam, size=(640,480))

threshold1 = 100
threshold2 = 200

for frame in cam.capture_continuous(raw_capture, format = “bgr”, use_video_port = True):

  • image = frame.array*
  • gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)*
  • edges = cv2.Canny(gray, threshold1, threshold2)*
  • image[edges>0] = (0,255,0)*
  • cv2.imshow(“Video”, image)*
  • if cv2.waitKey(1) & 0xFF == ord(‘q’):*
  • break*
  • raw_capture.truncate(0)*

and… Traceback (most recent call last):
File “/home/pi/kanny.py”, line 4, in
from picamera.array import PIRGBArray
ImportError: cannot import name ‘PIRGBArray’ from ‘picamera.array’ (/usr/lib/python3/dist-packages/picamera/array.py)

Welcome. This is the forum for OpenCV.

To receive support for this picamera package, contact the authors/maintainers of that package.