•  USB CAMERA
                        3.1  Capture from USB cam
                step1:ต่อ USB camera ใน pi
              step2:พิมพ์ code 
               fswebcam -r 1280x720 -S 20 image04.jpg


                  step3:สามารถดูรูปได้ที่ file Manager
      

               


                 3.2  Press switch control capture

                 step1: Install fswebcam
                
                           step2:  สร้าง folderที่จะเก็บรูปไว้ โดยพิมพ์codeลงในterminal 
                               folderจะอยู่ใน file manager ชื่อว่า xCapture




                            step3:ต่อวงจรดังรูป


                           step4: พิมพ์ code แล้วsave ว่า cam1
                     
import os
import time
import RPi.GPIO as GPIO

time.sleep(1)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(12,GPIO.IN,pull_up_down = GPIO.PUD_UP)
print"=====================Ready================="

while True:
        if(GPIO.input(12)==0):
            GPIO.output(11,GPIO.HIGH)
            timestr = time.strftime("/home/pi/xCapture/%Y%m%d-%H%M%S.jpg")
            print"Capture"
            print('%s'%timestr)
            os.system('fswebcam -p YUYV -d /dev/video0 -r 640x480 %s'%timestr)
            time.sleep(4)
            GPIO.output(11,GPIO.LOW)
            time.sleep(1)
            print"------------------------"



       
                step5: ทดสอบ 
                เข้าที่ Terminal พิมพ์คําสั่ง sudo  python cam1.py (ชื่อไฟล์ที่save)
                กดปุ่มเมื่อจะถ่ายภาพ รูปภาพจะอยู่ในโฟลเดอร์ xCapture




ไม่มีความคิดเห็น:

แสดงความคิดเห็น