当前位置: 首页>>代码示例>>Python>>正文


Python Log.output_msg方法代码示例

本文整理汇总了Python中common.Log.output_msg方法的典型用法代码示例。如果您正苦于以下问题:Python Log.output_msg方法的具体用法?Python Log.output_msg怎么用?Python Log.output_msg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.Log的用法示例。


在下文中一共展示了Log.output_msg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Log

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import output_msg [as 别名]
from common import Log
from proc_image import ProcImage


#======= Global Variable =======

log = Log(os.environ.has_key('NB_LOG_LEVEL'))


#======= Main Function =======

if __name__ == '__main__':


    #======= Start Message =======

    log.output_msg(1, 1, "main() started")
    log.output_msg(1, 1, "log.log_level = {0}".format(log.log_level))


    #======= Start Process =======

    app = ProcImage()
    app.get_image()


    #======= End Message =======

    log.output_msg(1, 1, "main() ended")

开发者ID:nasebanal,项目名称:nb-device4iot,代码行数:31,代码来源:get_image.py

示例2: ProcImage

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import output_msg [as 别名]
class ProcImage():

    """
    Class to process images
    """


    #======= Process Image =======

    def proc_image(self):

        """
        Function to process image
        """

        #----- No Processing -----

        if self.procmode == 0:

            self.img_output = self.img_input


        #----- Flip Flop -----

        elif self.procmode == 1:

            self.img_output = cv2.flip(self.img_input, flipCode = 0)


        #----- Canny -----

        elif self.procmode == 2:

            self.img_output = cv2.Canny(self.img_input, 50, 150)


        #----- Face Recognition -----

        elif self.procmode == 3:


            #----- Copy Mat -----

            self.img_output = self.img_input.copy()


            #----- Get Face Object -----

            faces = self.cascade_face.detectMultiScale(
                self.img_output,
                scaleFactor=1.1,
                minNeighbors=3,
                flags=cv2.CASCADE_SCALE_IMAGE,
                minSize=(0,0)
            )

        #----- Depict Face region -----

        for x, y, w, h in faces:

            #----- Depict rectangle for each face -----

            cv2.rectangle(
                self.img_output,
                (x-self.face_margin_x, y-self.face_margin_y),
                (x+w+self.face_margin_x, y+h+self.face_margin_y),
                COLOR[2],
                self.rect_width
            )


    #======= Get Movies =======

    def get_movie(self):

        """
        Function to get video
        """

        #======= Start Message =======

        self.log.output_msg(1, 1, "ProcImage.get_movie() started")


        #======= Open Camera =======

        with picamera.PiCamera() as camera:


            #======= Open Window =======

            cv2.namedWindow('input')
            cv2.namedWindow('output')


            #======= Prepare Video Recorder =======

            video = cv2.VideoWriter(
                self.output_video,
                cv2.VideoWriter_fourcc('H','2','6','4'),
#.........这里部分代码省略.........
开发者ID:nasebanal,项目名称:nb-device4iot,代码行数:103,代码来源:proc_image.py

示例3: ProcAlert

# 需要导入模块: from common import Log [as 别名]
# 或者: from common.Log import output_msg [as 别名]
class ProcAlert():

    """
    Class to process alert
    """


    #======= alert_led =======

    def alert_led(self):

        """
        Function to light LED
        """

        #======= Start Message =======

        self.log.output_msg(1, 1, "ProcAlert.alert_led() started")


        #======= Switch LED =======

        if self.alert_flag == 1:

            GPIO.output(self.led_pos, GPIO.HIGH)

        else:
            
            GPIO.output(self.led_pos, GPIO.LOW)


        #======= End Message =======

        self.log.output_msg(1, 1, "ProcAlert.alert_led() ended")


    #======= Get Alert =======

    def get_alert(self):

        """
        Function to capture alert
        """

        #======= Start Message =======

        self.log.output_msg(1, 1, "ProcAlert.get_alert() started")


        #======= Get Alert =======

        response = requests.get( self.endpoint )
        self.alert_flag = response.json()[0]['alert_flag']

        self.log.output_msg(1, 1, "self.alert_flag = {0}".format(self.alert_flag))


        #======= End Message =======

        self.log.output_msg(1, 1, "ProcAlert.get_alert() ended")


    #======= Initialization =======

    def __init__(self):

        """
        Constructor
        """

        #======= Setup Log =======

        self.log = Log(os.environ.has_key('NB_LOG_LEVEL'))


        #======= Start Message =======

        self.log.output_msg(1, 1, "ProcAlert.__init__() started")


        #======= Setup ProcMode =======

        if os.environ.has_key('NB_PROCMODE'):
            self.procmode = int(os.environ['NB_PROCMODE'])
        else:
            self.procmode = 1

        self.log.output_msg(1, 1, "self.procmode = {0}".format(self.procmode))


        #======= Setup Waiting Time =======

        if os.environ.has_key('NB_WAITING_TIME'):
            self.waiting_time = int(os.environ['NB_WAITING_TIME'])
        else:
            self.waiting_time = 1

        self.log.output_msg(1, 1, "self.waiting_time = {0}".format(self.waiting_time))


#.........这里部分代码省略.........
开发者ID:nasebanal,项目名称:nb-device4iot,代码行数:103,代码来源:proc_alert.py


注:本文中的common.Log.output_msg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。