-
Where did you get the camera module(s)?
Arducam website -
Model number of the product(s)?
Multi_Adapter_Board_2Channel_uc444 -
What hardware/platform were you working on?
Raspberry Pi -
Instructions you have followed. (link/manual/etc.)
RaspberryPi/Multi_Camera_Adapter/Multi_Adapter_Board_2Channel_uc444 at master · ArduCAM/RaspberryPi · GitHub -
Problems you were having?
Write Error failed when switching between two I2c channel -
The dmesg log from your hardware?
Write:error -
Troubleshooting attempts you’ve made?
-
What help do you need?
Im trying to build a camera system that can take picture and save it to folder. I am using a multi channel adapter that switch between two camera. I have a button that let two camera take the picture. First camera A will take picture and save it in a folder then camera two will take a picture and save it in a folder. The problem i have is that when i press that button everything just freezes and it wrote error failed and im not sure why.
Here is my code:
from picamera import PiCamera
import RPi.GPIO as GPIO
import os
import time
from tkinter import *
camera = PiCamera()
root = Tk()
root.attributes(’-fullscreen’, True)
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
i =1
i2c1 = “i2cset -y 1 0x70 0x00 0x01”
i2c2 = “i2cset -y 1 0x70 0x00 0x02”
NumA = 0
NumB = 0
GPIO.setup(7,GPIO.OUT)
GPIO.setup(11,GPIO.OUT)
x = 0
#initialization
for x in range(0,10):
os.system(i2c1)
GPIO.output(7,False)
GPIO.output(11,False)
time.sleep(0.2)
os.system(i2c2)
GPIO.output(7,True)
time.sleep(0.2)
x += 1
path = “/home/pi/camera”
def command():
brightness = 50
contrast = 0
saturation = 0
rotate = 0
auto_exposure = 0
exposure_time = 1000
def main():
os.system(i2c1)
GPIO.output(7,False)
GPIO.output(11,False)
camera.start_preview()
time.sleep(0.1)
#camera.capture("/home/pi/camera/ImageBPy.png")
camera.stop_preview()
os.system(i2c2) #0x02 bus
GPIO.output(7,True)
camera.start_preview()
time.sleep(0.1)
#camera.capture("/home/pi/camera/ImageAy.png")
camera.stop_preview()
def folder_counter():
global NumA
global NumB
ParentA = '/home/pi/camera/CameraA/'
ParentB = '/home/pi/camera/CameraB/'
Number_of_fileA = os.listdir(ParentA)
Number_of_fileB = os.listdir(ParentB)
NumA = len(Number_of_fileA) + 1
NumB = len(Number_of_fileB) + 1
return NumA,NumB
def shutter_button():
folder_counter()
time.sleep(0.3)
os.system(i2c1) #0x01 bus
GPIO.output(7,False)
GPIO.output(11,False)
filename = "/home/pi/camera/CameraA/image" + str(NumA) + ".jpg"
camera.capture(filename)
time.sleep(0.3)
os.system(i2c2) #0x02 bus
GPIO.output(7,True)
filename = "/home/pi/camera/CameraB/image" + str(NumB) + ".jpg"
camera.capture(filename)
def previewModeA():
time.sleep(0.2)
os.system(i2c1)
GPIO.output(7,False)
GPIO.output(11,False)
camera.start_preview()
camera.preview_fullscreen = False
camera.preview_window = (100,110,420,440)
def previewModeB():
time.sleep(0.2)
os.system(i2c2)
GPIO.output(7,True)
camera.start_preview()
camera.preview_fullscreen = False
camera.preview_window = (520,110,420,440)
def Button_off():
time.sleep(0.2)
os.system(i2c1)
GPIO.output(7,False)
GPIO.output(11,False)
camera.start_preview()
camera.preview_fullscreen = False
camera.preview_window = (100,100,320,240)
camera.stop_preview()
GPIO.cleanup()
exit()
#The disable_event function is used by root.protocol to disable the “X” button
def disable_event():
pass
root.title(“GMU research”)
Initialize tkinter window with dimensions 800 x 400
root.geometry(‘800x400’)
#creating new session button
new_session_button = Button(root, text = “new_session”, command = root.destroy)
new_session_button.place(x = 150, y = 60)
Creating a Button
linearize_button = Button(root, text=‘linearize’, command=root.destroy)
linearize_button.place(x=259, y=60)
shutter_button = Button(root, text = ‘Shutter’,command = shutter_button)
shutter_button.place(x=333, y=60)
resume_live_preview = Button(root, text = ‘PreviewModeA’, command = previewModeA)
resume_live_preview.place(x=405, y=60)
visual_system_button = Button(root,text = “previewModeB”, command = previewModeB)
visual_system_button.place(x=530,y=60)
citation_information = Button(root, text = “end session”, command = Button_off)
citation_information.place(x=650,y=60)
help_button = Button(root, text = “Help”)
help_button.place(x=747, y=60)
the root.protocol disables “X” button on the frame.
root.protocol(“WM_DELETE_WINDOW”, disable_event)
root.mainloop()
im not sure whats wrong with it.