Page 1 of 1

[SOLVED} what is the Compute Module's pin_config section?

Posted: Mon Oct 08, 2018 11:04 am
by gks9754
I have done detecting dual camera on my CM3 IO board.

I'm trying to use that two cameras but I'm wondering .."The Compute Module's pin_config section needs the second camera's LED and power enable pins configured" and "In the Compute Module's pin_defines section of the dts file, change the NUM_CAMERAS parameter to 2 and add the following:" How to do that...?

I thing I should write on somewhere..but i don't know which file I should write on
"pin@p31 { function = "output"; termination = "no_pulling"; };" and

"pin_define@CAMERA_1_LED { type = "internal"; number = <30>; };
pin_define@CAMERA_1_SHUTDOWN { type = "internal"; number = <31>; };
pin_define@CAMERA_1_UNICAM_PORT { type = "internal"; number = <0>; };
pin_define@CAMERA_1_I2C_PORT { type = "internal"; number = <0>; };
pin_define@CAMERA_1_SDA_PIN { type = "internal"; number = <28>; };
pin_define@CAMERA_1_SCL_PIN { type = "internal"; number = <29>; };"



I read this https://www.raspberrypi.org/documentati ... -camera.md

Re: what is the Compute Module's pin_config section?

Posted: Mon Oct 08, 2018 11:16 am
by PhilE
You'll find the information you need in the Pin Configuration documentation.

Re: what is the Compute Module's pin_config section?

Posted: Thu Oct 11, 2018 5:14 am
by gks9754
Turns out I already did it . but my program doesn't work..

Code: Select all

import time
import picamera
import RPi.GPIO as GPIO

CameraOne = picamera.PiCamera(0)
CameraTwo = picamera.PiCamera(1)

CameraOne.resolution = (854,480)
CameraTwo.resolution = (854,480)

CameraOne.framerate = 30
CameraTwo.framerate = 30

GPIO.setmode(GPIO.BCM)

with picamera.PiCamera() as camera:
    
    CameraOne.start_preview(resolution = (854,480))
    time.sleep(1)
    CameraTwo.start_preview(resolution = (854,480))
    time.sleep(5)
        
    CameraOne.capture('/home/pi/Desktop/capture1.jpg')
    CameraTwo.capture('/home/pi/Desktop/capture2.jpg')
 
    CameraOne.stop_preview
    CameraTwo.stop_preview
It shows me like this

Code: Select all

Python 3.5.3 (/usr/bin/python3)
>>> %Run recording_test2.py
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 345, in __init__
    }[(GPIO.RPI_REVISION, camera_num)]
KeyError: (3, 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/Desktop/PIcamera/recording_test2.py", line 6, in <module>
    CameraTwo = picamera.PiCamera(1)
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 350, in __init__
    GPIO.RPI_REVISION, camera_num))
picamera.exc.PiCameraError: Unable to determine default GPIO LED pin for RPi revision 3 and camera num 1
>>> 

Re: what is the Compute Module's pin_config section?

Posted: Thu Oct 11, 2018 6:37 am
by 6by9
Before trying picamera, does raspistill work for both cameras? Use -cs 0 and -cs 1 to select the camera.

Read the docs for picamera https://picamera.readthedocs.io/en/rele ... l#picamera
The led_pin parameter can be used to specify the GPIO pin which should be used to control the camera’s LED via the led attribute. If this is not specified, it should default to the correct value for your Pi platform. You should only need to specify this parameter if you are using a custom DeviceTree blob (this is only typical on the Compute Module platform).

Re: what is the Compute Module's pin_config section?

Posted: Mon Oct 15, 2018 8:25 am
by gks9754
Do you mean I'm going to do "raspistill -o image.jpg" and "raspistill -l image.jpg"??(I couldn't understand -cs0, -cs1)

I tried to do "raspistill -o image.jpg" it shows me CAM1 screen, when I did "raspistill -l image.jpg" It also shows me CAM1 screen.

I think I have to do something for working raspistill.

what should I do..

Re: what is the Compute Module's pin_config section?

Posted: Mon Oct 15, 2018 8:45 am
by 6by9

Code: Select all

raspistill -cs 0 -o image0.jpg
raspistill -cs 1 -o image1.jpg
Note that -cs X matches the CAMERA_X_ defines in pins_config section. With the default setup of

Code: Select all

pin_define@CAMERA_0_UNICAM_PORT { type = "internal"; number = <1>; };
..
pin_define@CAMERA_1_UNICAM_PORT { type = "internal"; number = <0>; };
-cs 0 will select the camera connected to CAM1, and -cs 1 will select the camera connected to CAM0. The reasoning is that CAM1 can support 4 lane CSI-2 (vs only 2 lanes on CAM0) and therefore being the more capable port is the one that should be used first. It's also the one that is used on all other flavours of the Pi.

Re: what is the Compute Module's pin_config section?

Posted: Mon Oct 15, 2018 9:57 am
by gks9754
Thanks!!! I've checked what you said

Code: Select all

raspistill -cs 0 -o image0.jpg
raspistill -cs 1 -o image1.jpg
It works well!!
but when I do

Code: Select all

import time
import picamera
import RPi.GPIO as GPIO

CameraOne = picamera.PiCamera(0)
CameraTwo = picamera.PiCamera(1)

CameraOne.resolution =(854,480)
CameraTwo.resolution =(854,480)

CameraOne.framerate = 30
CameraTwo.framerate = 30

GPIO.setmode(GPIO.BCM)

with picamera.PiCamera() as camera:

    CameraOne.start_preview(resolution = (854,480))
    time.sleep(1)
    CameraTwo.start_preview(resolution =  (854,480))

    CameraOne.capture('/home/pi/Desktop/capture1.jpg')
    CameraTwo.capture('/home/pi/Desktop/capture2.jpg')

    CameraOne.stop_preview
    CameraTwo.stop_preview

It shows me the same error..

Code: Select all

Python 3.5.3 (/usr/bin/python3)
>>> %Run 'dual camera test.py'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 345, in __init__
    }[(GPIO.RPI_REVISION, camera_num)]
KeyError: (3, 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/dual camera test.py", line 6, in <module>
    CameraTwo = picamera.PiCamera(1)
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 350, in __init__
    GPIO.RPI_REVISION, camera_num))
picamera.exc.PiCameraError: Unable to determine default GPIO LED pin for RPi revision 3 and camera num 1
>>> 
could you tell me more details??
Do I have to change the picamera library..?

Re: what is the Compute Module's pin_config section?

Posted: Mon Oct 15, 2018 10:04 am
by 6by9
I'll point you straight back to my earlier post
6by9 wrote:
Thu Oct 11, 2018 6:37 am
Read the docs for picamera https://picamera.readthedocs.io/en/rele ... l#picamera
The led_pin parameter can be used to specify the GPIO pin which should be used to control the camera’s LED via the led attribute. If this is not specified, it should default to the correct value for your Pi platform. You should only need to specify this parameter if you are using a custom DeviceTree blob (this is only typical on the Compute Module platform).

Code: Select all

CameraOne = picamera.PiCamera(camera_num=0,led_pin=2)
CameraTwo = picamera.PiCamera(camera_num=1,led_pin=30)

Re: what is the Compute Module's pin_config section?

Posted: Thu Oct 18, 2018 8:20 am
by gks9754
I did it!!!!!!!!!!!

thanks!!!!