Skip to content

Commit c971162

Browse files
feat: minMaxLoc function refactor
1 parent 94a9295 commit c971162

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

cpp/FOCV_Function.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -513,16 +513,22 @@ jsi::Object FOCV_Function::invoke(jsi::Runtime& runtime, const jsi::Value* argum
513513
double min = 0;
514514
double max = 0;
515515

516+
Point minLoc; Point maxLoc;
517+
516518
if (count > 2) {
517519
auto mask = args.asMatPtr(2);
518520

519-
cv::minMaxIdx(*src, &min, &max, NULL, NULL, *mask);
521+
cv::minMaxLoc(*src, &min, &max, &minLoc, &maxLoc, *mask);
520522
} else {
521-
cv::minMaxIdx(*src, &min, &max);
523+
cv::minMaxLoc(*src, &min, &max, &minLoc, &maxLoc);
522524
}
523525

524526
value.setProperty(runtime, "minVal", jsi::Value(min));
525527
value.setProperty(runtime, "maxVal", jsi::Value(max));
528+
value.setProperty(runtime, "minX", minLoc.x);
529+
value.setProperty(runtime, "minY", minLoc.y);
530+
value.setProperty(runtime, "maxX", maxLoc.x);
531+
value.setProperty(runtime, "maxY", maxLoc.y);
526532
} break;
527533
case hashString("mulSpectrums", 12): {
528534
auto a = args.asMatPtr(1);

docs/pages/availablefunctions.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,14 @@ invoke(
778778
name: 'minMaxLoc',
779779
src: Mat,
780780
mask?: Mat
781-
): { minVal: number; maxVal: number };
781+
): {
782+
minVal: number;
783+
maxVal: number;
784+
minX: number;
785+
minY: number;
786+
maxX: number;
787+
maxY: number;
788+
};
782789
```
783790

784791
### mulSpectrums

src/functions/Core.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,14 @@ export type Core = {
623623
name: 'minMaxLoc',
624624
src: Mat,
625625
mask?: Mat
626-
): { minVal: number; maxVal: number };
626+
): {
627+
minVal: number;
628+
maxVal: number;
629+
minX: number;
630+
minY: number;
631+
maxX: number;
632+
maxY: number;
633+
};
627634

628635
/**
629636
* Performs the per-element multiplication of two Fourier spectrums

0 commit comments

Comments
 (0)