Skip to content

Commit 04d5992

Browse files
bbox: Update with new coordinate API
1 parent 8521781 commit 04d5992

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

bounding-box/app/bounding_box_example.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
#include <syslog.h>
2828
#include <unistd.h>
2929

30+
// Select scene or frame normalized coordinates.
31+
//
32+
// Scene coordinate system is normalized to [0,0]-[1,1] and follows the filmed scene,
33+
// i.e. static objects in the world have the same coordinates regardless of global rotation.
34+
//
35+
// Frame coordinate system is normalized and aligned with the camera frame,
36+
// i.e. top-left is [0,0] and bottom-right is [1,1].
37+
static bool scene_normalized = true;
38+
3039
volatile sig_atomic_t running = 1;
3140

3241
static void shutdown(int status) {
@@ -69,6 +78,11 @@ static void example_single_channel(void) {
6978
if (!bbox)
7079
panic("Failed creating: %s", strerror(errno));
7180

81+
if (scene_normalized)
82+
bbox_coordinates_scene_normalized(bbox);
83+
else
84+
bbox_coordinates_frame_normalized(bbox);
85+
7286
bbox_clear(bbox); // Remove all old bounding-boxes
7387

7488
// Create all needed colors [These operations are slow!]
@@ -222,9 +236,16 @@ int main(void) {
222236
init_signals();
223237

224238
for (bool once = true; running; once = false) {
239+
scene_normalized = true;
225240
example_single_channel();
226-
example_multiple_channels();
241+
227242
example_clear();
243+
244+
scene_normalized = false;
245+
example_single_channel();
246+
247+
example_multiple_channels();
248+
228249
if (once)
229250
syslog(LOG_INFO, "All examples succeeded.");
230251
}

0 commit comments

Comments
 (0)