Skip to content

Commit 606d984

Browse files
refactor: remove unused code
1 parent 2b7497c commit 606d984

10 files changed

Lines changed: 9 additions & 333 deletions

File tree

apps/computer-vision/components/vision_camera/tasks/OCRTask.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { OCR_ENGLISH, OCRDetection, useOCR } from 'react-native-executorch';
66
import Svg, { Polygon, Text as SvgText } from 'react-native-svg';
77
import { TaskProps } from './types';
88

9-
type Props = TaskProps & { activeModel: string };
9+
type Props = Omit<TaskProps, 'activeModel'>;
1010

1111
export default function OCRTask({
1212
canvasSize,

packages/react-native-executorch/common/rnexecutorch/models/VisionModel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ class VisionModel : public BaseModel {
148148
/**
149149
* @brief Read orientation metadata from JSI frameData object.
150150
*
151-
* Reads orientation, isMirrored, frameWidth, frameHeight.
152-
* Falls back to "up"/false/0/0 if fields are absent (e.g. when
151+
* Reads orientation and isMirrored.
152+
* Falls back to "up"/false if fields are absent (e.g. when
153153
* enablePhysicalBufferRotation is used — transform will then be a no-op).
154154
*/
155155
utils::FrameOrientation extractFrameOrientation(

packages/react-native-executorch/common/rnexecutorch/tests/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,6 @@ add_rn_test(FrameProcessorTests unit/FrameProcessorTest.cpp
165165
LIBS opencv_deps android
166166
)
167167

168-
add_rn_test(FrameTransformTests unit/FrameTransformTest.cpp
169-
SOURCES
170-
${RNEXECUTORCH_DIR}/utils/FrameTransform.cpp
171-
LIBS opencv_deps
172-
)
173-
174168
add_rn_test(BaseModelTests integration/BaseModelTest.cpp)
175169

176170
add_rn_test(VisionModelTests integration/VisionModelTest.cpp

packages/react-native-executorch/common/rnexecutorch/tests/unit/FrameTransformTest.cpp

Lines changed: 0 additions & 212 deletions
This file was deleted.

packages/react-native-executorch/common/rnexecutorch/utils/FrameProcessor.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,7 @@ FrameOrientation readFrameOrientation(jsi::Runtime &runtime,
4949
isMirrored = val.getBool();
5050
}
5151

52-
int frameWidth = 0;
53-
if (obj.hasProperty(runtime, "frameWidth")) {
54-
auto val = obj.getProperty(runtime, "frameWidth");
55-
if (val.isNumber())
56-
frameWidth = static_cast<int>(val.asNumber());
57-
}
58-
59-
int frameHeight = 0;
60-
if (obj.hasProperty(runtime, "frameHeight")) {
61-
auto val = obj.getProperty(runtime, "frameHeight");
62-
if (val.isNumber())
63-
frameHeight = static_cast<int>(val.asNumber());
64-
}
65-
66-
return {orientation, isMirrored, frameWidth, frameHeight};
52+
return {orientation, isMirrored};
6753
}
6854

6955
cv::Mat pixelsToMat(const JSTensorViewIn &pixelData) {

packages/react-native-executorch/common/rnexecutorch/utils/FrameProcessor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ cv::Mat frameToMat(jsi::Runtime &runtime, const jsi::Value &frameData);
3131
/**
3232
* @brief Read orientation metadata from a VisionCamera frameData JSI object.
3333
*
34-
* Reads orientation, isMirrored, frameWidth, frameHeight from the frameData
35-
* object. Falls back to "up"/false/0/0 if fields are absent (e.g. when
34+
* Reads orientation and isMirrored from the frameData object.
35+
* Falls back to "up"/false if fields are absent (e.g. when
3636
* enablePhysicalBufferRotation is used — transform will be a no-op).
3737
*/
3838
FrameOrientation readFrameOrientation(jsi::Runtime &runtime,

packages/react-native-executorch/common/rnexecutorch/utils/FrameTransform.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,7 @@
11
#include "FrameTransform.h"
2-
#include <cassert>
32

43
namespace rnexecutorch::utils {
54

6-
void transformBbox(float &x1, float &y1, float &x2, float &y2,
7-
const FrameOrientation &orient) {
8-
const float w = static_cast<float>(orient.frameWidth);
9-
const float h = static_cast<float>(orient.frameHeight);
10-
11-
// Flip horizontally first
12-
if (orient.isMirrored) {
13-
float nx1 = w - x2;
14-
float nx2 = w - x1;
15-
x1 = nx1;
16-
x2 = nx2;
17-
}
18-
19-
// Sensor native = landscape-left — apply CW rotation for all orientations.
20-
{
21-
float nx1 = h - y2, ny1 = x1;
22-
float nx2 = h - y1, ny2 = x2;
23-
x1 = nx1;
24-
y1 = ny1;
25-
x2 = nx2;
26-
y2 = ny2;
27-
}
28-
}
29-
30-
cv::Mat transformMat(const cv::Mat &mat, const FrameOrientation &orient) {
31-
cv::Mat result = mat.clone();
32-
33-
// Flip first
34-
if (orient.isMirrored) {
35-
cv::flip(result, result, 1);
36-
}
37-
38-
// Sensor native = landscape-left — apply CW rotation.
39-
cv::rotate(result, result, cv::ROTATE_90_CLOCKWISE);
40-
41-
return result;
42-
}
43-
445
cv::Mat rotateFrameForModel(const cv::Mat &mat,
456
const FrameOrientation &orient) {
467
cv::Mat result = mat.clone();

packages/react-native-executorch/common/rnexecutorch/utils/FrameTransform.h

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,8 @@ namespace rnexecutorch::utils {
1212
struct FrameOrientation {
1313
std::string orientation; // "up"|"right"|"left"|"down"
1414
bool isMirrored;
15-
int frameWidth; // raw frame width (sensor native, before any rotation)
16-
int frameHeight; // raw frame height (sensor native, before any rotation)
1715
};
1816

19-
/**
20-
* @brief Transform a bounding box from raw frame pixel space to screen space.
21-
*
22-
* Maps coordinates from raw frame pixel space to screen space.
23-
* orientation describes how the buffer is rotated relative to screen,
24-
* so we apply that same rotation (not its inverse) to map buffer points
25-
* into screen space. Applies flip (if isMirrored) first, then rotation.
26-
* Coordinates are absolute pixels in the raw frame (not normalized [0,1]).
27-
* x1/y1 = top-left corner, x2/y2 = bottom-right corner.
28-
* After transform, x1<=x2 and y1<=y2 are guaranteed.
29-
*/
30-
void transformBbox(float &x1, float &y1, float &x2, float &y2,
31-
const FrameOrientation &orient);
32-
33-
/**
34-
* @brief Rotate/flip a cv::Mat from raw frame space to screen space.
35-
*
36-
* Returns a new mat (does not modify input).
37-
* For right/left orientations, output rows/cols are swapped vs input.
38-
*/
39-
cv::Mat transformMat(const cv::Mat &mat, const FrameOrientation &orient);
40-
4117
/**
4218
* @brief Rotate/flip a cv::Mat so the model sees an upright image.
4319
*
@@ -69,33 +45,6 @@ void inverseRotateBbox(float &x1, float &y1, float &x2, float &y2,
6945
*/
7046
cv::Mat inverseRotateMat(const cv::Mat &mat, const FrameOrientation &orient);
7147

72-
/**
73-
* @brief Transform 4-point bbox from raw frame pixel space to screen space.
74-
*
75-
* Templated on point type — requires P to have float x and y members.
76-
* Applies same flip-then-rotate logic as transformBbox, per point.
77-
* Template implementation in header (required for templates).
78-
*/
79-
template <typename P>
80-
void transformPoints(std::array<P, 4> &points, const FrameOrientation &orient) {
81-
const float w = static_cast<float>(orient.frameWidth);
82-
const float h = static_cast<float>(orient.frameHeight);
83-
84-
for (auto &p : points) {
85-
float x = p.x;
86-
float y = p.y;
87-
88-
// Flip first
89-
if (orient.isMirrored) {
90-
x = w - x;
91-
}
92-
93-
// Sensor native = landscape-left — apply CW rotation for all orientations.
94-
p.x = h - y;
95-
p.y = x;
96-
}
97-
}
98-
9948
/**
10049
* @brief Map 4-point bbox from rotated-frame space back to screen space.
10150
*

0 commit comments

Comments
 (0)