perf: bound local mosaic rendering and skip unused tracking grayscale

这个提交包含在:
mac 于 2026-11-08 17:56:14 +08:00 提交
1 父节点 f07b116398
当前提交 4b7e348ff5
11 个文件已更改
+129 -30

没有与搜索条件相匹配的文件

+10 -5
查看文件
@@ -239,14 +239,19 @@
if(_trackingCancelled.load())return [self finishToolAnalysis:@"已取消;保留最后连续可信轨迹" error:error];if(_trackingSingle&&_trackingSamples.count>=2)return [self finishToolAnalysis:nil error:error];if(_trackingSamples.count>=DYToolKeyLimit)return [self finishToolAnalysis:@"轨迹已到数量上限,保留已完成部分" error:error];
CMTime expected=CMTIME_IS_NUMERIC(_trackingPreviousTime)?(_trackingBackward?CMTimeSubtract(_trackingPreviousTime,_trackingFrameDuration):CMTimeAdd(_trackingPreviousTime,_trackingFrameDuration)):_trackingReferenceTime;if(!CMTIME_IS_NUMERIC(time)||time.epoch!=expected.epoch||CMTimeCompare(time,expected)!=0)return [self stopToolAnalysis:@"宿主帧序列不连续,停在最后可信帧" error:error];
NSDictionary *preview=nil;
dy::GrayFrame frame=[self toolGrayFrame:tile preview:(_trackingSingle&&!_trackingObjectMode)?nullptr:&preview error:error];
if(!frame.valid())return [self stopToolAnalysis:@"宿主未返回完整源画面" error:error];
dy::GrayFrame frame;
const bool stamp=_trackingStampMotion.active;
const bool objectMode=_trackingObjectMode&&!stamp;
// The object tracker consumes only the small color image. The gray frame
// is useful at the seed only when checking orientation against a cached frame.
const bool needsGray=!objectMode||(!_trackingSamples.count&&_trackingReferenceFrame.valid());
if(![self captureTrackingTile:tile gray:needsGray?&frame:nullptr preview:(!_trackingSingle||objectMode)?&preview:nullptr error:error])
return [self stopToolAnalysis:@"宿主未返回完整源画面" error:error];
if(!_trackingSamples.count){if(_trackingReferenceFrame.valid()&&frame.width==_trackingReferenceFrame.width&&frame.height==_trackingReferenceFrame.height){double same=0,flip=0;size_t count=0;for(int y=0;y<frame.height;y+=8)for(int x=0;x<frame.width;x+=8){float p=frame.at(y*frame.width+x);same+=fabs(p-_trackingReferenceFrame.at(y*frame.width+x));flip+=fabs(p-_trackingReferenceFrame.at((frame.height-1-y)*frame.width+x));count++;}same/=MAX(size_t(1),count);flip/=MAX(size_t(1),count);_trackingFlip=flip<.035&&flip+.008<same&&flip<same*.8;}os_log(OS_LOG_DEFAULT,"dayu_tool_track_seed width=%{public}d height=%{public}d flip=%{public}d time=%{public}.6f",frame.width,frame.height,(int)_trackingFlip,CMTimeGetSeconds(time));}
if(_trackingFlip)frame.flipVertically();
BOOL stamp=_trackingStampMotion.active;
if(!objectMode&&_trackingFlip)frame.flipVertically();
dy::TrackResult target,source;
dy::ObjectStep objectStep;
if(_trackingObjectMode&&!stamp){
if(objectMode){
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){