fix: 添加分析错误处理和调试输出
This commit is contained in:
39
scheduler.py
39
scheduler.py
@@ -152,24 +152,27 @@ class VisionScheduler:
|
||||
|
||||
def analyze_now(self, image_id):
|
||||
"""立即分析指定图片"""
|
||||
image = db.get_image_by_id(image_id)
|
||||
if not image:
|
||||
return {'success': False, 'error': '图片不存在'}
|
||||
|
||||
result = self.analyzer.analyze(image['path'])
|
||||
|
||||
if result['success']:
|
||||
for event in result['events']:
|
||||
db.add_event(
|
||||
image_id,
|
||||
event['event_type'],
|
||||
event['description'],
|
||||
event['confidence']
|
||||
)
|
||||
db.mark_image_analyzed(image_id)
|
||||
self.last_analyze_time = datetime.datetime.now().isoformat()
|
||||
|
||||
return result
|
||||
try:
|
||||
image = db.get_image_by_id(image_id)
|
||||
if not image:
|
||||
return {'success': False, 'error': '图片不存在'}
|
||||
|
||||
result = self.analyzer.analyze(image['path'])
|
||||
|
||||
if result['success']:
|
||||
for event in result['events']:
|
||||
db.add_event(
|
||||
image_id,
|
||||
event['event_type'],
|
||||
event['description'],
|
||||
event['confidence']
|
||||
)
|
||||
db.mark_image_analyzed(image_id)
|
||||
self.last_analyze_time = datetime.datetime.now().isoformat()
|
||||
|
||||
return result
|
||||
except Exception as e:
|
||||
return {'success': False, 'error': str(e)}
|
||||
|
||||
def analyze_unanalyzed(self):
|
||||
"""分析所有未分析的图片"""
|
||||
|
||||
Reference in New Issue
Block a user