Skip to content

Commit 4a8a64a

Browse files
feat: resize function
1 parent 6a4c8cb commit 4a8a64a

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

cpp/FOCV_Function.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,16 @@ jsi::Object FOCV_Function::invoke(jsi::Runtime& runtime, const jsi::Value* argum
654654

655655
cv::repeat(*src, ny, nx, *dst);
656656
} break;
657+
case hashString("resize", 6): {
658+
auto src = args.asMatPtr(1);
659+
auto dst = args.asMatPtr(2);
660+
auto dsize = args.asSizePtr(3);
661+
auto fx = args.asNumber(4);
662+
auto fy = args.asNumber(5);
663+
auto interpolation = args.asNumber(6);
664+
665+
cv::resize(*src, *dst, *dsize, fx, fy, interpolation);
666+
} break;
657667
case hashString("rotate", 6): {
658668
auto src = args.asMatPtr(1);
659669
auto dst = args.asMatPtr(2);

docs/pages/availablefunctions.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,29 @@ Fills the output array with repeated copies of the input array
991991
invoke(name: 'repeat', src: Mat, ny: number, nx: number, dst: Mat): void;
992992
```
993993

994+
### resize
995+
996+
The function resize resizes the image src down to or up to the specified size. Note that the initial dst type or size are not taken into account. Instead, the size and type are derived from the `src`,`dsize`,`fx`, and `fy`.
997+
998+
- src input image.
999+
- dst output image; it has the size dsize (when it is non-zero) or the size computed from src.size(), fx, and fy; the type of dst is the same as of src.
1000+
- dsize output image size
1001+
- fx scale factor along the horizontal axis
1002+
- fy scale factor along the vertical axis
1003+
- interpolation interpolation method, see #InterpolationFlags
1004+
1005+
```js
1006+
invoke(
1007+
name: 'resize',
1008+
src: Mat,
1009+
dst: Mat,
1010+
dsize: Size,
1011+
fx: number,
1012+
fy: number,
1013+
interpolation: InterpolationFlags
1014+
): void;
1015+
```
1016+
9941017
### rotate
9951018

9961019
Rotates matrix.

src/functions/Core.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
SortFlags,
1212
} from '../constants/Core';
1313
import type { DataTypes } from '../constants/DataTypes';
14+
import type { InterpolationFlags } from '../constants/ImageTransform';
1415
import type {
1516
Mat,
1617
MatVector,
@@ -19,6 +20,7 @@ import type {
1920
PointVector,
2021
Rect,
2122
Scalar,
23+
Size,
2224
} from '../objects/Objects';
2325

2426
export type Core = {
@@ -797,6 +799,28 @@ export type Core = {
797799
*/
798800
invoke(name: 'repeat', src: Mat, ny: number, nx: number, dst: Mat): void;
799801

802+
/**
803+
* The function resize resizes the image src down to or up to the specified size. Note that the
804+
* initial dst type or size are not taken into account. Instead, the size and type are derived from
805+
* the `src`,`dsize`,`fx`, and `fy`.
806+
* @param name Function name.
807+
* @param src input image.
808+
* @param dst output image; it has the size dsize (when it is non-zero) or the size computed from src.size(), fx, and fy; the type of dst is the same as of src.
809+
* @param dsize output image size
810+
* @param fx scale factor along the horizontal axis
811+
* @param fy scale factor along the vertical axis
812+
* @param interpolation interpolation method, see #InterpolationFlags
813+
*/
814+
invoke(
815+
name: 'resize',
816+
src: Mat,
817+
dst: Mat,
818+
dsize: Size,
819+
fx: number,
820+
fy: number,
821+
interpolation: InterpolationFlags
822+
): void;
823+
800824
/**
801825
* Rotates matrix.
802826
* @param name Function name.

0 commit comments

Comments
 (0)