mirror of
http://git.xinwangdao.com/cnnc-embedded-parts-detect/detect-gui.git
synced 2025-06-24 13:14:11 +08:00
1、image framework
This commit is contained in:
parent
747d110897
commit
d51db0bf36
@ -196,6 +196,7 @@ class ImageFramework(EdgeComponent):
|
|||||||
self.data_callback = None
|
self.data_callback = None
|
||||||
self.location_thread = None
|
self.location_thread = None
|
||||||
self.process_thread = None
|
self.process_thread = None
|
||||||
|
self.thread_running = False
|
||||||
|
|
||||||
def configure(self, setting: Settings) -> None:
|
def configure(self, setting: Settings) -> None:
|
||||||
self.init_image_framework_sdk()
|
self.init_image_framework_sdk()
|
||||||
@ -272,19 +273,25 @@ class ImageFramework(EdgeComponent):
|
|||||||
|
|
||||||
@service()
|
@service()
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if self.location_thread is not None:
|
super().stop()
|
||||||
self.location_thread.join()
|
self.stop_location()
|
||||||
if self.process_thread is not None:
|
# self.image_framework_sdk.LibapiStop()
|
||||||
self.process_thread.join()
|
|
||||||
|
|
||||||
self.image_framework_sdk.stop_sdk()
|
|
||||||
self.logger.info("Image framework stopped.")
|
self.logger.info("Image framework stopped.")
|
||||||
|
|
||||||
@service()
|
@service()
|
||||||
def start_location(self):
|
def start_location(self):
|
||||||
|
self.thread_running = True
|
||||||
self.location_thread.start()
|
self.location_thread.start()
|
||||||
self.process_thread.start()
|
self.process_thread.start()
|
||||||
|
|
||||||
|
@service()
|
||||||
|
def stop_location(self):
|
||||||
|
self.thread_running = False
|
||||||
|
if self.location_thread is not None:
|
||||||
|
self.location_thread.join()
|
||||||
|
if self.process_thread is not None:
|
||||||
|
self.process_thread.join()
|
||||||
|
|
||||||
@service()
|
@service()
|
||||||
def start_detect(self):
|
def start_detect(self):
|
||||||
global g_running_mode
|
global g_running_mode
|
||||||
@ -317,7 +324,7 @@ class ImageFramework(EdgeComponent):
|
|||||||
global g_msg_cache, g_frame_cache, g_running_mode
|
global g_msg_cache, g_frame_cache, g_running_mode
|
||||||
# 打开广角摄像头
|
# 打开广角摄像头
|
||||||
capture = cv2.VideoCapture(0)
|
capture = cv2.VideoCapture(0)
|
||||||
while True:
|
while self.thread_running:
|
||||||
# 如果当前不是定位模式,不处理任何事务
|
# 如果当前不是定位模式,不处理任何事务
|
||||||
if g_running_mode != RUNNING_MODE_LOCATION:
|
if g_running_mode != RUNNING_MODE_LOCATION:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
@ -345,7 +352,7 @@ class ImageFramework(EdgeComponent):
|
|||||||
def _main_processing_thread(self):
|
def _main_processing_thread(self):
|
||||||
global g_msg_cache, g_frame_cache, g_running_mode
|
global g_msg_cache, g_frame_cache, g_running_mode
|
||||||
|
|
||||||
while True:
|
while self.thread_running:
|
||||||
if len(g_msg_cache) <= 0:
|
if len(g_msg_cache) <= 0:
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user