Page 457 - MDP2020-1
P. 457

················································································  명장양성프로젝트  【MDP】  과제발표회  자료집  Ⅰ    |  451


                4)  BGR  값을  HSV  값으로  변환


            import  numpy  as  np
            import  cv2

            color  =  [0,255,0]
            pixel  =  np.uint8([[color]])
            hsv  =  cv2.cvtColor(pixel,  cv2.COLOR_BGR2HSV)
            hsv  =  hsv[0][0]

            print("bgr:  ",  color)
            print("hsv:  ",  hsv)


                5)  안드로이드스튜디오와  라즈베리파이  연동


            import  RPi.GPIO  as  GPIO

            import  time
            import  firebase_admin
            from  firebase_admin  import  db
            from  firebase_admin  import  credentials

            GPIO.setmode(GPIO.BCM)
            GPIO.setup(18,  GPIO.IN)
            GPIO.setup(23,  GPIO.OUT)
            busyStatus  =  ["relax",  "normal",  "busy"]
            i  =  0
            temp  =  GPIO.input(18)

            print('setting  on')
            cred  =  credentials.Certificate('/home/pi/MDP/subway-intec-9fdee5fe3d1f.json')
            firebase_admin.initialize_app(cred,  {'databaseURL':  'https://subway-intec.firebaseio.com/'})
            ref  =  db.reference('reference')
            print('set  ref')

            ref.update({'busy':  busyStatus[i]})
            print('set  busy')
            while  True:
              if  not  temp  ==  GPIO.input(18):
                if  GPIO.input(18)  ==  1:

                  GPIO.output(23,  True)
                  ref.update({'busy':  busyStatus[1]})
                elif  GPIO.input(18)  ==  0:
                  GPIO.output(23,  False)
                  ref.update({'busy':  busyStatus[2]})

                temp  =  GPIO.input(18)
   452   453   454   455   456   457   458   459   460   461   462