Skip to content

Commit 150daf9

Browse files
refactor: changes suggested by claude
1 parent 606d984 commit 150daf9

9 files changed

Lines changed: 17 additions & 13 deletions

File tree

apps/computer-vision/app/vision_camera/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export default function VisionCameraScreen() {
221221
outputs={frameOutput ? [frameOutput] : []}
222222
isActive={isFocused}
223223
format={format}
224-
orientationSource="device"
224+
orientationSource="interface"
225225
/>
226226

227227
{/* Layout sentinel — measures the full-screen area for bbox/canvas sizing */}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function ClassificationTask({
7575
scheduleOnRN(updateClass, { label: bestLabel, score: bestScore });
7676
}
7777
} catch {
78-
// ignore
78+
// Frame may be disposed before processing completes — transient, safe to ignore.
7979
} finally {
8080
frame.dispose();
8181
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default function OCRTask({
7272
});
7373
}
7474
} catch {
75-
// ignore
75+
// Frame may be disposed before processing completes — transient, safe to ignore.
7676
} finally {
7777
frame.dispose();
7878
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default function ObjectDetectionTask({
9393
});
9494
}
9595
} catch {
96-
// ignore
96+
// Frame may be disposed before processing completes — transient, safe to ignore.
9797
} finally {
9898
frame.dispose();
9999
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export default function SegmentationTask({
185185
if (img) scheduleOnRN(updateMask, img);
186186
}
187187
} catch {
188-
// ignore
188+
// Frame may be disposed before processing completes — transient, safe to ignore.
189189
} finally {
190190
frame.dispose();
191191
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default function StyleTransferTask({
121121
if (img) scheduleOnRN(updateImage, img);
122122
}
123123
} catch {
124-
// ignore
124+
// Frame may be disposed before processing completes — transient, safe to ignore.
125125
} finally {
126126
frame.dispose();
127127
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ namespace rnexecutorch::utils {
44

55
cv::Mat rotateFrameForModel(const cv::Mat &mat,
66
const FrameOrientation &orient) {
7+
if (!orient.isMirrored && orient.orientation == "up") {
8+
return mat.clone();
9+
}
10+
711
cv::Mat result = mat.clone();
812

913
if (orient.isMirrored) {
@@ -28,23 +32,23 @@ void inverseRotateBbox(float &x1, float &y1, float &x2, float &y2,
2832
const float h = static_cast<float>(rH);
2933

3034
if (orient.orientation == "up") {
31-
// CW: nx = h - y, ny = x
35+
// landscape-left → portrait: nx = h - y, ny = x
3236
float nx1 = h - y2, ny1 = x1;
3337
float nx2 = h - y1, ny2 = x2;
3438
x1 = nx1;
3539
y1 = ny1;
3640
x2 = nx2;
3741
y2 = ny2;
3842
} else if (orient.orientation == "right") {
39-
// 180°: nx = w - x, ny = h - y
43+
// upside-down portrait → portrait: nx = w - x, ny = h - y
4044
float nx1 = w - x2, ny1 = h - y2;
4145
float nx2 = w - x1, ny2 = h - y1;
4246
x1 = nx1;
4347
y1 = ny1;
4448
x2 = nx2;
4549
y2 = ny2;
4650
} else if (orient.orientation == "down") {
47-
// CCW: nx = y, ny = w - x
51+
// landscape-right → portrait: nx = y, ny = w - x
4852
float nx1 = y1, ny1 = w - x2;
4953
float nx2 = y2, ny2 = w - x1;
5054
x1 = nx1;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ void inverseRotatePoints(std::array<P, 4> &points,
6363
float y = p.y;
6464

6565
if (orient.orientation == "up") {
66-
// CW: nx = h-y, ny = x
66+
// landscape-left → portrait: nx = h-y, ny = x
6767
p.x = h - y;
6868
p.y = x;
6969
} else if (orient.orientation == "right") {
70-
// 180°: nx = w-x, ny = h-y
70+
// upside-down portrait → portrait: nx = w-x, ny = h-y
7171
p.x = w - x;
7272
p.y = h - y;
7373
} else if (orient.orientation == "down") {
74-
// CCW: nx = y, ny = w-x
74+
// landscape-right → portrait: nx = y, ny = w-x
7575
p.x = y;
7676
p.y = w - x;
7777
}

packages/react-native-executorch/src/modules/computer_vision/VisionModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export abstract class VisionModule<TOutput> extends BaseModule {
5252
* onFrame(frame) {
5353
* 'worklet';
5454
* if (!runOnFrame) return;
55-
* const result = runOnFrame(frame);
55+
* const result = runOnFrame(frame, isMirrored);
5656
* frame.dispose();
5757
* }
5858
* });

0 commit comments

Comments
 (0)