Implement adaptive inspector, mask clock repair, and selectable face mosaic; validation pending

这个提交包含在:
mac 于 2026-11-06 15:56:42 +08:00 提交
1 父节点 f05cf05451
当前提交 3b4c612edf
19 个文件已更改
+245 -103

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

@@ -61,6 +61,33 @@ if(faceFixture.length){
privacy[@"mosaic"] = @{@"enabled":@NO,@"source":@"face",@"size":@64};BOOL privacyOff=[face renderSource:src destination:dst uniforms:privacyU paths:@{} spider:nil tools:privacy colorManagement:nil hostPrimaries:kFxColorPrimaries_Rec709 error:&maskError];Pixels privateReference=read(dst,gpu);
double privateInside=0,privateOutside=0;for(NSUInteger y=85;y<145;y++)for(NSUInteger x=200;x<260;x++)for(int c=0;c<3;c++)privateInside=MAX(privateInside,fabs((float)privateFrame[(y*w+x)*4+c]-(float)privateReference[(y*w+x)*4+c]));for(NSUInteger y=410;y<470;y++)for(NSUInteger x=410;x<470;x++)for(int c=0;c<3;c++)privateOutside=MAX(privateOutside,fabs((float)privateFrame[(y*w+x)*4+c]-(float)privateReference[(y*w+x)*4+c]));
run.record(@"mosaic-real-face-includes-feature-region-and-excludes-background",privacyOK&&privacyOff&&privateInside>.05&&privateOutside==0,@{@"faceChange":@(privateInside),@"backgroundChange":@(privateOutside)});
// The same production menu writer turns two detected faces into independent,
// serializable masks, then toggles only one while preserving the other pixels.
privacy[@"mosaic"]=@{@"enabled":@YES,@"source":@"face",@"size":@64};
BOOL fastOK=[face renderSource:twoSource destination:twoDest uniforms:privacyU paths:@{} spider:nil tools:DYToolRenderSnapshot(privacy,kCMTimeZero) colorManagement:nil hostPrimaries:kFxColorPrimaries_Rec709 error:&maskError];
NSDictionary *detected=[face mosaicFaceSnapshot];Pixels bothFaces=read(twoDest,gpu);
run.record(@"mosaic-fast-rectangles-detect-two-faces-without-landmarks",fastOK&&[detected[@"boxes"]count]==2,@{@"faces":@([detected[@"boxes"]count])});
if([detected[@"boxes"]count]==2){
DYDiagnosticManager *base=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(base,nil);DYWriteTools(base,privacy,kCMTimeZero);
DYToolCanvasProbe *host=[[[DYToolCanvasProbe alloc]init]autorelease];host->_base=base;host->_time=kCMTimeZero;
id bridge=[[NSClassFromString(@"DYViewerParameterBridge")alloc]initWithAPIManager:host];[bridge setValue:face forKey:@"renderer"];
NSMenuItem *item=[[[NSMenuItem alloc]init]autorelease];item.representedObject=@{@"importFaces":detected,@"actionTime":detected[@"time"]};
int undo=base->_undoStarts;[bridge performSelector:@selector(applyMosaicMenu:) withObject:item];
NSDictionary *saved=DYReadTools(host,kCMTimeZero).document;NSArray *IDs=saved[@"mosaic"][@"maskIDs"];
run.record(@"mosaic-import-faces-creates-two-stable-masks-in-one-undo",IDs.count==2&&DYSharedMasks(saved).count==2&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1);
BOOL savedOK=[face renderSource:twoSource destination:twoDest uniforms:privacyU paths:@{} spider:nil tools:DYToolRenderSnapshot(saved,kCMTimeZero) colorManagement:nil hostPrimaries:kFxColorPrimaries_Rec709 error:&maskError];
run.record(@"mosaic-imported-selection-matches-live-two-face-render",savedOK&&difference(bothFaces,read(twoDest,gpu)).maximum<.002);
if(IDs.count==2){
item.representedObject=@{@"toggleMask":IDs[1]};[bridge performSelector:@selector(applyMosaicMenu:) withObject:item];saved=DYReadTools(host,kCMTimeZero).document;
[face renderSource:twoSource destination:twoDest uniforms:privacyU paths:@{} spider:nil tools:DYToolRenderSnapshot(saved,kCMTimeZero) colorManagement:nil hostPrimaries:kFxColorPrimaries_Rec709 error:&maskError];Pixels single=read(twoDest,gpu);
privacy[@"mosaic"]=@{@"enabled":@NO,@"source":@"face",@"size":@64};[face renderSource:twoSource destination:twoDest uniforms:privacyU paths:@{} spider:nil tools:privacy colorManagement:nil hostPrimaries:kFxColorPrimaries_Rec709 error:&maskError];Pixels reference=read(twoDest,gpu);
double left=0,right=0;for(NSUInteger y=0;y<512;y++)for(NSUInteger x=0;x<1024;x++)for(int c=0;c<3;c++){double delta=fabs((float)single[(y*1024+x)*4+c]-(float)reference[(y*1024+x)*4+c]);if(x<512)left=MAX(left,delta);else right=MAX(right,delta);}
run.record(@"mosaic-selects-one-person-with-other-person-pixel-identical",left>.05&&right==0&&[saved[@"mosaic"][@"maskIDs"]count]==1,@{@"selectedChange":@(left),@"unselectedChange":@(right)});
NSData *archive=[NSKeyedArchiver archivedDataWithRootObject:DYReadTools(host,kCMTimeZero) requiringSecureCoding:YES error:nil];DYToolDocument *restored=[NSKeyedUnarchiver unarchivedObjectOfClass:DYToolDocument.class fromData:archive error:nil];run.record(@"mosaic-person-selection-survives-secure-save-and-reopen",[restored.document isEqual:saved]);
NSMutableDictionary *malformed=DYMutablePlist(saved);malformed[@"mosaic"][@"maskIDs"]=@[IDs[0],IDs[0]];run.record(@"mosaic-duplicate-mask-identities-rejected",!DYValidToolDocument(malformed));
}
[bridge invalidate];[bridge release];
}
Pixels noFace(w*h*4);for(NSUInteger i=0;i<w*h;i++){noFace[i*4]=.35;noFace[i*4+1]=.18;noFace[i*4+2]=.1;noFace[i*4+3]=1;}upload(noFace);u.skinVisualize=0;Pixels noFaceProtected=render(run,face,src,dst,gpu,u,@{},@"face-none-protected-render");u.skinProtection.x=0;Pixels noFacePlain=render(run,face,src,dst,gpu,u,@{},@"face-none-unprotected-reference");run.record(@"face-no-detection-clears-prior-frame-and-fails-closed",difference(noFaceProtected,noFacePlain).maximum<.002);
}