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

**URL:** <https://forum.opencv.org/t/pirgbarray-from-picamera-array-help-please/14033>\
**Category:** Uncategorized\
**Tags:** programming, raspberrypi\
**Created:** [July 26, 2023, 12:44pm UTC](https://forum.opencv.org/t/pirgbarray-from-picamera-array-help-please/14033 "2023-07-26T12:44:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angelika](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@Angelika](https://forum.opencv.org/u/Angelika)\
**Post date:** [July 26, 2023, 12:44pm UTC](https://forum.opencv.org/t/pirgbarray-from-picamera-array-help-please/14033/1 "2023-07-26T12:44:57Z")

</div>

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)\*  
_cv2.destroyAllWindows()_  
_cam.close()_

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)

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [July 26, 2023, 5:05pm UTC](https://forum.opencv.org/t/pirgbarray-from-picamera-array-help-please/14033/2 "2023-07-26T17:05:58Z")

</div>

Welcome. This is the forum for OpenCV.

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

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [July 26, 2023, 5:06pm UTC](https://forum.opencv.org/t/pirgbarray-from-picamera-array-help-please/14033/3 "2023-07-26T17:06:03Z")

</div>

Closed on July 26, 2023, 5:06pm UTC


