Replace every production tracking path with Apple Vision; remove OpenCV linkage
这个提交包含在:
1 父节点
dbab2ab0cc
当前提交
8af7013ad4
22 个文件已更改
+600
-43
没有与搜索条件相匹配的文件
@@ -218,7 +218,7 @@
|
||||
}
|
||||
std::vector<dy::FlowPoint>polygon;NSData *nodes=_trackingCandidate[@"nodes"];if(_trackingSeed.kind==DYMaskBezier){auto path=dyFlattenMask((const DYBezierNode*)nodes.bytes,nodes.length/sizeof(DYBezierNode));for(int i=0;i<path.count;i++)polygon.push_back({path.x[i],path.y[i]});}else if(_trackingSeed.kind==DYMaskRectangle)polygon={{-.5f,-.5f},{.5f,-.5f},{.5f,.5f},{-.5f,.5f}};else for(int i=0;i<128;i++){float angle=i*(2.f*M_PI/128);polygon.push_back({.5f*std::cos(angle),.5f*std::sin(angle)});}
|
||||
if(_trackingStampMotion.active)_stampSourceTracker.setMask(polygon);
|
||||
_toolTracker.setMask(std::move(polygon));return YES;
|
||||
_trackingShapePolygon=polygon;_toolTracker.setMask(std::move(polygon));return YES;
|
||||
}
|
||||
- (BOOL)finishToolTrackingLoss:(const dy::TrackResult&)lost region:(NSString*)region atTime:(CMTime)time error:(NSError**)error {
|
||||
NSString *reason=@"区域内运动不一致";
|
||||
@@ -250,21 +250,17 @@
|
||||
NSData *rgba=preview[@"rgba"];int width=[preview[@"width"]intValue],height=[preview[@"height"]intValue];
|
||||
if(width<16||height<16||width>640||height>640||rgba.length!=size_t(width)*height*4)return [self finishToolAnalysis:@"目标跟踪未取得完整分析画面,原轨迹已保留" error:error];
|
||||
if(!_trackingSamples.count){
|
||||
// Vision consumes an axis-aligned object rectangle. Track the true bounds
|
||||
// of a rotated authored shape, then apply only its uniform scale/position.
|
||||
float aspect=float(width)/height,ca=std::cos(_trackingSeed.angle),sa=std::sin(_trackingSeed.angle);
|
||||
float w=_trackingSeed.width*aspect,h=_trackingSeed.height;
|
||||
BOOL ellipse=_trackingSeed.kind==DYMaskEllipse;
|
||||
float bw=ellipse?std::hypot(w*ca,h*sa):fabs(w*ca)+fabs(h*sa);
|
||||
float bh=ellipse?std::hypot(w*sa,h*ca):fabs(w*sa)+fabs(h*ca);
|
||||
dy::TrackerROI roi={_trackingSeed.centerX,_trackingSeed.centerY,bw/aspect,bh,0};
|
||||
dy::TrackerROI seed={_trackingSeed.centerX,_trackingSeed.centerY,_trackingSeed.width,_trackingSeed.height,_trackingSeed.angle};
|
||||
dy::TrackerROI roi=dy::visionMaskBounds(seed,_trackingShapePolygon,float(width)/height);_trackingObjectROI=roi;
|
||||
os_log(OS_LOG_DEFAULT,"dayu_object_track_worker main=%{public}d",(int)NSThread.isMainThread);
|
||||
if(!_objectTracker.reset((const uint8_t*)rgba.bytes,width,height,_trackingFlip,roi,1./CMTimeGetSeconds(_trackingFrameDuration)))return [self finishToolAnalysis:@"无法建立目标外观,请调整蒙版后重试" error:error];
|
||||
objectStep={{roi.cx,roi.cy,roi.width,roi.height,1},true,false,false,0};
|
||||
}else objectStep=_objectTracker.track((const uint8_t*)rgba.bytes,width,height,_trackingFlip);
|
||||
target=_objectTracker.result(objectStep);
|
||||
target.cx+=(_trackingSeed.centerX-_trackingObjectROI.cx)*target.scale;target.cy+=(_trackingSeed.centerY-_trackingObjectROI.cy)*target.scale;
|
||||
if(!target.valid)return [self finishToolAnalysis:@"目标未能重新确认,已停止;请调整蒙版后继续" error:error];
|
||||
}else if(!_trackingSamples.count){
|
||||
os_log(OS_LOG_DEFAULT,"dayu_vision_region_worker main=%{public}d stamp=%{public}d",(int)NSThread.isMainThread,(int)stamp);
|
||||
dy::TrackerROI targetROI={_trackingSeed.centerX,_trackingSeed.centerY,_trackingSeed.width,_trackingSeed.height,_trackingSeed.angle};
|
||||
if(!_toolTracker.reset(frame,targetROI))
|
||||
return [self finishToolAnalysis:stamp?@"覆盖区域内纹理不足,原图章已保留":@"蒙版内纹理不足,原蒙版已保留" error:error];
|
||||
|
||||
在新工单中引用
屏蔽一个用户