Don't overwrite detection options if not specified in setOptions()
PiperOrigin-RevId: 520790479
This commit is contained in:
parent
508c72ddc9
commit
145fc1ed38
|
@ -140,6 +140,11 @@ export class GestureRecognizer extends VisionTaskRunner {
|
|||
new HandGestureRecognizerGraphOptions();
|
||||
this.options.setHandGestureRecognizerGraphOptions(
|
||||
this.handGestureRecognizerGraphOptions);
|
||||
this.handDetectorGraphOptions.setMinDetectionConfidence(DEFAULT_CONFIDENCE);
|
||||
this.handLandmarkerGraphOptions.setMinTrackingConfidence(
|
||||
DEFAULT_CONFIDENCE);
|
||||
this.handLandmarksDetectorGraphOptions.setMinDetectionConfidence(
|
||||
DEFAULT_CONFIDENCE);
|
||||
}
|
||||
|
||||
protected override get baseOptions(): BaseOptionsProto {
|
||||
|
@ -162,12 +167,20 @@ export class GestureRecognizer extends VisionTaskRunner {
|
|||
override setOptions(options: GestureRecognizerOptions): Promise<void> {
|
||||
this.handDetectorGraphOptions.setNumHands(
|
||||
options.numHands ?? DEFAULT_NUM_HANDS);
|
||||
if ('minHandDetectionConfidence' in options) {
|
||||
this.handDetectorGraphOptions.setMinDetectionConfidence(
|
||||
options.minHandDetectionConfidence ?? DEFAULT_CONFIDENCE);
|
||||
}
|
||||
|
||||
if ('minTrackingConfidence' in options) {
|
||||
this.handLandmarkerGraphOptions.setMinTrackingConfidence(
|
||||
options.minTrackingConfidence ?? DEFAULT_CONFIDENCE);
|
||||
}
|
||||
|
||||
if ('minHandPresenceConfidence' in options) {
|
||||
this.handLandmarksDetectorGraphOptions.setMinDetectionConfidence(
|
||||
options.minHandPresenceConfidence ?? DEFAULT_CONFIDENCE);
|
||||
}
|
||||
|
||||
if (options.cannedGesturesClassifierOptions) {
|
||||
// Note that we have to support both JSPB and ProtobufJS and cannot
|
||||
|
|
|
@ -147,6 +147,18 @@ describe('GestureRecognizer', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('does not reset default values when not specified', async () => {
|
||||
await gestureRecognizer.setOptions({minHandDetectionConfidence: 0.5});
|
||||
await gestureRecognizer.setOptions({});
|
||||
verifyGraph(gestureRecognizer, [
|
||||
[
|
||||
'handLandmarkerGraphOptions', 'handDetectorGraphOptions',
|
||||
'minDetectionConfidence'
|
||||
],
|
||||
0.5
|
||||
]);
|
||||
});
|
||||
|
||||
describe('setOptions()', () => {
|
||||
interface TestCase {
|
||||
optionPath: [keyof GestureRecognizerOptions, ...string[]];
|
||||
|
|
Loading…
Reference in New Issue
Block a user