Skip to content

Commit 4551e50

Browse files
chore: minor library improvements
1 parent afb0b0d commit 4551e50

File tree

7 files changed

+29
-98
lines changed

7 files changed

+29
-98
lines changed

cpp/FOCV_Function.cpp

+1-37
Original file line numberDiff line numberDiff line change
@@ -1232,49 +1232,13 @@ jsi::Object FOCV_Function::invoke(jsi::Runtime& runtime, const jsi::Value* argum
12321232

12331233
cv::threshold(*src, *dst, thresh, maxval, type);
12341234
} break;
1235-
case hashString("calcOpticalFlowPyrLK", 20): {
1236-
auto prevImg = args.asMatPtr(1);
1237-
auto nextImg = args.asMatPtr(2);
1238-
auto prevPts = args.asMatPtr(3);
1239-
auto nextPts = args.asMatPtr(4);
1240-
auto status = args.asMatPtr(5);
1241-
auto err = args.asMatPtr(6);
1242-
1243-
if (count > 7) {
1244-
auto winSize = args.asSizePtr(7);
1245-
if (count > 8) {
1246-
auto maxLevel = args.asNumber(8);
1247-
if (count > 9) {
1248-
auto termCriteria = args.asTermCriteriaPtr(9);
1249-
if (count > 10) {
1250-
auto flags = args.asNumber(10);
1251-
if (count > 11) {
1252-
auto minEigThreshold = args.asNumber(11);
1253-
1254-
cv::calcOpticalFlowPyrLK(*prevImg, *nextImg, *prevPts, *nextPts, *status, *err, *winSize, maxLevel, *termCriteria, flags, minEigThreshold);
1255-
break;
1256-
}
1257-
cv::calcOpticalFlowPyrLK(*prevImg, *nextImg, *prevPts, *nextPts, *status, *err, *winSize, maxLevel, *termCriteria, flags);
1258-
break;
1259-
}
1260-
cv::calcOpticalFlowPyrLK(*prevImg, *nextImg, *prevPts, *nextPts, *status, *err, *winSize, maxLevel, *termCriteria);
1261-
break;
1262-
}
1263-
cv::calcOpticalFlowPyrLK(*prevImg, *nextImg, *prevPts, *nextPts, *status, *err, *winSize, maxLevel);
1264-
break;
1265-
}
1266-
cv::calcOpticalFlowPyrLK(*prevImg, *nextImg, *prevPts, *nextPts, *status, *err, *winSize);
1267-
break;
1268-
}
1269-
cv::calcOpticalFlowPyrLK(*prevImg, *nextImg, *prevPts, *nextPts, *status, *err);
1270-
} break;
12711235
case hashString("matchTemplate", 13): {
12721236
auto image = args.asMatPtr(1);
12731237
auto templ = args.asMatPtr(2);
12741238
auto result = args.asMatPtr(3);
12751239
auto method = args.asNumber(4);
12761240
auto mask = args.asMatPtr(5);
1277-
1241+
12781242
cv::matchTemplate(*image, *templ, *result, method, *mask);
12791243
} break;
12801244
case hashString("phaseCorrelate", 14): {

cpp/FOCV_Storage.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
#include "FOCV_Storage.hpp"
9+
#include <set>
910

1011
std::unordered_map<std::string, std::any> FOCV_Storage::items = std::unordered_map<std::string, std::any>();
1112

@@ -18,4 +19,4 @@ void FOCV_Storage::clear(const std::set<std::string> &ids_to_keep) {
1819
it = items.erase(it);
1920
}
2021
}
21-
}
22+
}

cpp/FOCV_Storage.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <stdio.h>
1212
#include <any>
13+
#include <set>
1314
#include "UUID.hpp"
1415

1516
#ifdef __cplusplus

example/ios/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ PODS:
936936
- React-Mapbuffer (0.74.4):
937937
- glog
938938
- React-debug
939-
- react-native-fast-opencv (0.3.3):
939+
- react-native-fast-opencv (0.3.4):
940940
- DoubleConversion
941941
- FastOpenCV-iOS (= 1.0.4)
942942
- glog
@@ -1633,7 +1633,7 @@ SPEC CHECKSUMS:
16331633
React-jsitracing: 4e9c99e73a6269b27b0d4cbab277dd90df3e5ac0
16341634
React-logger: fbfb50e2a2b1b46ee087f0a52739fadecc5e81a4
16351635
React-Mapbuffer: d39610dff659d8cf1fea485abae08bbf6f9c8279
1636-
react-native-fast-opencv: 973f3a99309db23b4ebded20de36757c790d1ec5
1636+
react-native-fast-opencv: 35b0442a0b585bc919de50a28344e5454c024b13
16371637
react-native-image-picker: c3afe5472ef870d98a4b28415fc0b928161ee5f7
16381638
react-native-safe-area-context: 4532f1a0c5d34a46b9324ccaaedcb5582a302b7d
16391639
react-native-skia: e2b30a7cca22f5daef0ed243d18de58403e7a997

example/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
"dependencies": {
1313
"@react-navigation/native": "^6.1.18",
1414
"@react-navigation/native-stack": "^6.11.0",
15-
"@shopify/react-native-skia": "^1.3.10",
15+
"@shopify/react-native-skia": "^1.8.2",
1616
"react": "18.2.0",
1717
"react-native": "0.74.4",
1818
"react-native-image-picker": "^7.1.2",
1919
"react-native-reanimated": "^3.14.0",
2020
"react-native-safe-area-context": "^4.11.0",
2121
"react-native-screens": "^3.34.0",
22-
"react-native-vision-camera": "^4.5.2",
23-
"react-native-worklets-core": "^1.3.3",
24-
"vision-camera-resize-plugin": "^3.1.0"
22+
"react-native-vision-camera": "4.6.3",
23+
"react-native-worklets-core": "1.5.0",
24+
"vision-camera-resize-plugin": "3.2.0"
2525
},
2626
"devDependencies": {
2727
"@babel/core": "^7.20.0",

src/functions/ImageProcessing/ObjectDetection.ts

+2-37
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,7 @@
1-
import type {
2-
OpticalFlowFlags,
3-
TemplateMatchModes,
4-
} from '../../constants/ImageProcessing';
5-
import type { Mat, Point2f, Size, TermCriteria } from '../../objects/Objects';
1+
import type { TemplateMatchModes } from '../../constants/ImageProcessing';
2+
import type { Mat, Point2f } from '../../objects/Objects';
63

74
export type ObjectDetection = {
8-
/**
9-
* Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.
10-
* @param name Function name
11-
* @param prevImg First 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.
12-
* @param nextImg Second input image or pyramid of the same size and the same type as prevImg.
13-
* @param prevPts Vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers.
14-
* @param nextPts Output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image; when OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
15-
* @param status Output status vector (of unsigned chars); each element of the vector is set to 1 if the flow for the corresponding features has been found, otherwise, it is set to 0.
16-
* @param err Output vector of errors; each element of the vector is set to an error for the corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't found then the error is not defined (use the status parameter to find such cases).
17-
* @param winSize Size of the search window at each pyramid level.
18-
* @param maxLevel 0-based maximal pyramid level number; if set to 0, pyramids are not used (single level), if set to 1, two levels are used, and so on; if pyramids are passed to input then algorithm will use as many levels as pyramids have but no more than maxLevel.
19-
* @param criteria Parameter, specifying the termination criteria of the iterative search algorithm (after the specified maximum number of iterations criteria.maxCount or when the search window moves by less than criteria.epsilon).
20-
* @param flags Operation flags:
21-
* * OPTFLOW_USE_INITIAL_FLOW uses initial estimations, stored in nextPts; if the flag is not set, then prevPts is copied to nextPts and is considered the initial estimate.
22-
* * OPTFLOW_LK_GET_MIN_EIGENVALS use minimum eigen values as an error measure (see minEigThreshold description); if the flag is not set, then L1 distance between patches around the original and a moved point, divided by number of pixels in a window, is used as a error measure.
23-
* @param minEigThreshold The algorithm calculates the minimum eigen value of a 2x2 normal matrix of optical flow equations (this matrix is called a spatial gradient matrix in [36]), divided by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding feature is filtered out and its flow is not processed, so it allows to remove bad points and get a performance boost.
24-
*/
25-
invoke(
26-
name: 'calcOpticalFlowPyrLK',
27-
prevImg: Mat,
28-
nextImg: Mat,
29-
prevPts: Mat,
30-
nextPts: Mat,
31-
status: Mat,
32-
err: Mat,
33-
winSize?: Size,
34-
maxLevel?: number,
35-
criteria?: TermCriteria,
36-
flags?: OpticalFlowFlags,
37-
minEigThreshold?: number
38-
): void;
39-
405
/**
416
* Compares a template against overlapped image regions
427
* @param name Function name

yarn.lock

+17-17
Original file line numberDiff line numberDiff line change
@@ -3122,9 +3122,9 @@ __metadata:
31223122
languageName: node
31233123
linkType: hard
31243124

3125-
"@shopify/react-native-skia@npm:^1.3.10":
3126-
version: 1.5.5
3127-
resolution: "@shopify/react-native-skia@npm:1.5.5"
3125+
"@shopify/react-native-skia@npm:^1.8.2":
3126+
version: 1.8.2
3127+
resolution: "@shopify/react-native-skia@npm:1.8.2"
31283128
dependencies:
31293129
canvaskit-wasm: "npm:0.39.1"
31303130
react-reconciler: "npm:0.27.0"
@@ -3139,7 +3139,7 @@ __metadata:
31393139
optional: true
31403140
bin:
31413141
setup-skia-web: ./scripts/setup-canvaskit.js
3142-
checksum: 10/63a87986131e20c93824c017502458718d516f735bf54784e700f491adb8e7e59ef15055022cdcd69dafea429778f38c3e4293365660b8ed80e9c069a7191158
3142+
checksum: 10/7bb95d28aebcbf8537228069ace8788823c72783eabe0c8c48b7e11afe5c44c19b819aeaac823d4240c7aab542d7eaa2a02f24b045067400fbc038fa65ba2cd5
31433143
languageName: node
31443144
linkType: hard
31453145

@@ -11109,17 +11109,17 @@ __metadata:
1110911109
"@react-native/typescript-config": "npm:0.74.86"
1111011110
"@react-navigation/native": "npm:^6.1.18"
1111111111
"@react-navigation/native-stack": "npm:^6.11.0"
11112-
"@shopify/react-native-skia": "npm:^1.3.10"
11112+
"@shopify/react-native-skia": "npm:^1.8.2"
1111311113
react: "npm:18.2.0"
1111411114
react-native: "npm:0.74.4"
1111511115
react-native-builder-bob: "npm:^0.29.0"
1111611116
react-native-image-picker: "npm:^7.1.2"
1111711117
react-native-reanimated: "npm:^3.14.0"
1111811118
react-native-safe-area-context: "npm:^4.11.0"
1111911119
react-native-screens: "npm:^3.34.0"
11120-
react-native-vision-camera: "npm:^4.5.2"
11121-
react-native-worklets-core: "npm:^1.3.3"
11122-
vision-camera-resize-plugin: "npm:^3.1.0"
11120+
react-native-vision-camera: "npm:4.6.3"
11121+
react-native-worklets-core: "npm:1.5.0"
11122+
vision-camera-resize-plugin: "npm:3.2.0"
1112311123
languageName: unknown
1112411124
linkType: soft
1112511125

@@ -11210,9 +11210,9 @@ __metadata:
1121011210
languageName: node
1121111211
linkType: hard
1121211212

11213-
"react-native-vision-camera@npm:^4.5.2":
11214-
version: 4.6.1
11215-
resolution: "react-native-vision-camera@npm:4.6.1"
11213+
"react-native-vision-camera@npm:4.6.3":
11214+
version: 4.6.3
11215+
resolution: "react-native-vision-camera@npm:4.6.3"
1121611216
peerDependencies:
1121711217
"@shopify/react-native-skia": "*"
1121811218
react: "*"
@@ -11226,11 +11226,11 @@ __metadata:
1122611226
optional: true
1122711227
react-native-worklets-core:
1122811228
optional: true
11229-
checksum: 10/742f11a74ca9e3eb3a41c65ba8ac588925b539d6e232f6a2c9c60b2ebcf07997d9a1bca0ef3ac471bf2b6d7eb99a81985a352a73755f8f0ee4aba1898c3b10d1
11229+
checksum: 10/ff56e8126df423ba5d4c9f8d2b15a1b9b48e8669445464b2f301fa47946ce1759e6e4119c443cb8f02a44f8ab5fd6c52a8d534cfc385fc9d647e857ee46f82e6
1123011230
languageName: node
1123111231
linkType: hard
1123211232

11233-
"react-native-worklets-core@npm:^1.3.3":
11233+
"react-native-worklets-core@npm:1.5.0":
1123411234
version: 1.5.0
1123511235
resolution: "react-native-worklets-core@npm:1.5.0"
1123611236
dependencies:
@@ -13529,15 +13529,15 @@ __metadata:
1352913529
languageName: node
1353013530
linkType: hard
1353113531

13532-
"vision-camera-resize-plugin@npm:^3.1.0":
13533-
version: 3.1.0
13534-
resolution: "vision-camera-resize-plugin@npm:3.1.0"
13532+
"vision-camera-resize-plugin@npm:3.2.0":
13533+
version: 3.2.0
13534+
resolution: "vision-camera-resize-plugin@npm:3.2.0"
1353513535
peerDependencies:
1353613536
react: "*"
1353713537
react-native: "*"
1353813538
react-native-vision-camera: ">=4.0.1"
1353913539
react-native-worklets-core: ">=1.2.0"
13540-
checksum: 10/68c64d0c133f76ff7332606b6ee9c78e0db99b0f095228293172beeee8206045c50c24e8e28e67f702138942d97d43690c2ce784561d1eb0d02a5a50fedba7b1
13540+
checksum: 10/39f06e35e0fb92e77815d97d7967aec84c4875c99128d7178f2784a9b0f2967e76fc7bb608768d18ee618a64ae899e0318d688c3c9f8556534876b295f008244
1354113541
languageName: node
1354213542
linkType: hard
1354313543

0 commit comments

Comments
 (0)