if udp: 무슨 의미인가요 ?

조회수 502회
from lib.device import Camera
from lib.processors_noopenmdao import findFaceGetPulse
from lib.interface import plotXY, imshow, waitKey, destroyWindow
from cv2 import moveWindow
import argparse
import numpy as np
import datetime
#TODO: work on serial port comms, if anyone asks for it
#from serial import Serial
import socket
import sys

class getPulseApp(object):

    """
    Python application that finds a face in a webcam stream, then isolates the
    forehead.

    Then the average green-light intensity in the forehead region is gathered
    over time, and the detected person's pulse is estimated.
    """

    def __init__(self, args):
        # Imaging device - must be a connected camera (not an ip camera or mjpeg
        # stream)
        serial = args.serial
        baud = args.baud
        self.send_serial = False
        self.send_udp = False
        if serial:
            self.send_serial = True
            if not baud:
                baud = 9600
            else:
                baud = int(baud)
            self.serial = Serial(port=serial, baudrate=baud)

        udp = args.udp
        if udp:
            self.send_udp = True
            if ":" not in udp:
                ip = udp
                port = 5005
            else:
                ip, port = udp.split(":")
                port = int(port)
            self.udp = (ip, port)
            self.sock = socket.socket(socket.AF_INET, # Internet
                 socket.SOCK_DGRAM) # UDP

이 코딩 부분에서 if serial: , if udp: 이런 부분 잘 이해가 안갑니다 ..

p.s 검색해보니까 아마

money = true 
if money:
    print("택시를 타라")

이거 이용한거 같더라구요 근데 그럼 serial = true 랑 udp = true 랑은 무엇을 의미하는건가요?? 이해가 잘 안갑니다

1 답변

  • 좋아요

    2

    싫어요
    채택 취소하기

    파이썬에서 True 와 False 가 되는 경우를 잘 알고 있어야 합니다.

    1 -> True
    0 -> False
    "aaaa" -> True
    "" -> False
    [1, 2, 3] -> True
    [] -> False
    (1, 2, 3,) {'a':1} -> True
    (), {} -> False
    

    대충 위와 같습니다.

    args.udp 이므로 args로 어떤 값이 대입되는지를 알아야겠죠. boolean 타입일지...문자열일지...숫자형일지....즉 쉽게 값이 존재하면 처리하겠다는 의미입니다.

    • 아 이해했습니다 답변감사드립니다 송지섭 2019.2.25 17:31

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)