- import numpy as np
- import re
- import math
- import random
- import cv2
- import threading
- import time
- import logging
- logging.basicConfig(filename='log.log',level=logging.INFO,format='%(asctime)s %(message)s',
- datefmt='%m/%d/%Y %I:%M:%S %p')
- from rknn.api import RKNN
- INPUT_SIZE = 224
- INPUT_POSE = 224
- def model1():
- rknn = RKNN()
- rknn.load_rknn('./model.rknn')
- rknn.init_runtime()
- img = cv2.imread("test1.jpg")
-
- while True:
- time.sleep(1)
- img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
- img = cv2.resize(img, (INPUT_SIZE, INPUT_SIZE), interpolation=cv2.INTER_CUBIC)
- logging.info('--> Running age model')
- [outputs] = rknn.inference(inputs=[img])
- logging.info('age inference len result: '+ str(outputs))
- logging.info('age inference len result: ')
- def model2():
- rknn = RKNN()
- rknn.load_rknn('./model.rknn')
- rknn.init_runtime()
- img = cv2.imread("test2.jpg")
- while True:
- time.sleep(1)
- img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
- img = cv2.resize(img, (INPUT_POSE, INPUT_POSE), interpolation=cv2.INTER_CUBIC)
- logging.info('--> Running pose model')
- [outputs] = rknn.inference(inputs=[img])
- logging.info('pose inference len result: '+ str( outputs))
- logging.info('pose inference len result: ')
- def thread1():
- logging.info("start to run age thread")
- t = threading.Thread( target = model1)
- t.start()
- def thread2():
- logging.info("start to run pose thread")
- s = threading.Thread( target = model2)
- s.start()
- if __name__ == '__main__':
- thread1()
- thread2()
- while True:
-
- time.sleep(1)
- logging.info("XXXXX")
-
复制代码
代码xiaqing10 发表于 2019-6-1 02:52
附上简单的测试代码代码
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |