Skip to content

Commit ffd7b1c

Browse files
Merge pull request #28 from lukaszkurantdev/feat/crop-function
feat: crop function
2 parents 25f0cb2 + 7909302 commit ffd7b1c

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

cpp/FOCV_Function.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ jsi::Object FOCV_Function::invoke(jsi::Runtime& runtime, const jsi::Value* argum
276276
value.setProperty(runtime, "value", result);
277277
}
278278
} break;
279+
case hashString("crop", 4): {
280+
auto src = args.asMatPtr(1);
281+
auto dst = args.asMatPtr(2);
282+
auto rect = args.asRectPtr(3);
283+
284+
(*src)(*rect).copyTo(*dst);
285+
} break;
279286
case hashString("dct", 3): {
280287
auto src = args.asMatPtr(1);
281288
auto dst = args.asMatPtr(2);

docs/pages/availablefunctions.md

+12
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,18 @@ Counts non-zero array elements.
347347
invoke(name: 'countNonZero', src: MatVector | Mat): { value: number };
348348
```
349349

350+
### crop
351+
352+
This functions allows to crop Mat to selected size using Rect.
353+
354+
- src Source matrix
355+
- dst Destination matrix
356+
- roi Rectangle as ROI
357+
358+
```js
359+
invoke(name: 'crop', src: Mat, dst: Mat, roi: Rect): void;
360+
```
361+
350362
### dct
351363

352364
Performs a forward or inverse discrete Cosine transform of 1D or 2D array.

src/functions/Core.ts

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {
1616
MatVector,
1717
Point,
1818
PointVector,
19+
Rect,
1920
Scalar,
2021
} from '../objects/Objects';
2122

@@ -297,6 +298,15 @@ export type Core = {
297298
*/
298299
invoke(name: 'countNonZero', src: MatVector | Mat): { value: number };
299300

301+
/**
302+
* This functions allows to crop Mat to selected size using Rect.
303+
* @param name Function name.
304+
* @param src Source matrix
305+
* @param dst Destination matrix. If it does not have a proper size or type before the operation, it is reallocated
306+
* @param roi Rectangle as ROI
307+
*/
308+
invoke(name: 'crop', src: Mat, dst: Mat, roi: Rect): void;
309+
300310
/**
301311
* Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
302312
* @param name Function name.

0 commit comments

Comments
 (0)