Skip to content

Cameraの有効化

1
nano ~/mycar/myconfig.py

myconfig.py

1
2
3
4
5
6
# #CAMERA
CAMERA_TYPE = "PICAM"   # (PICAM|WEBCAM|CVCAM|CSIC|V4L|MOCK)
IMAGE_W = 160
IMAGE_H = 120
IMAGE_DEPTH = 3         # default RGB=3, make 1 for mono
# CAMERA_FRAMERATE = DRIVE_LOOP_HZ

カメラのエラー発生の原因

カメラ右側のネジと部品が接触し、エラーが発生する場合があります。対処方法として、右側に絶縁性のスペーサーを取り付けるかすることで、接触によるエラーを防ぐことが可能です。

カメラで発生するエラー例

PiCAMERAが認識できてない場合は、下記のようなエラーが発生します。PiCameraとRaspberryPi3間のケーブルがねじれるために、断線をおこすことが多いようです。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
python manage.py drive --js
using donkey v3.1.0 ...
loading config file: /home/pi/mycar/config.py
loading personal config over-rides

config loaded
cfg.CAMERA_TYPE PICAM
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 456, in _init_camera
    self._camera = mo.MMALCamera()
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2279, in __init__
    super(MMALCamera, self).__init__()
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 633, in __init__
    prefix="Failed to create MMAL component %s" % self.component_type)
  File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
    raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.ril.camera': Out of memory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 552, in <module>
    meta=args['--meta'])
  File "manage.py", line 96, in drive
    cam = PiCamera(image_w=cfg.IMAGE_W, image_h=cfg.IMAGE_H, image_d=cfg.IMAGE_DEPTH)
  File "/home/pi/projects/donkeycar/donkeycar/parts/camera.py", line 20, in __init__
    self.camera = PiCamera() #PiCamera gets resolution (height, width)
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 431, in __init__
    self._init_camera(camera_num, stereo_mode, stereo_decimate)
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 460, in _init_camera
    "Camera is not enabled. Try running 'sudo raspi-config' "
picamera.exc.PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled.