forked from acquire-project/acquire-driver-hdcam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set shape before offset to avoid offset oob
- Loading branch information
Showing
3 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ else() | |
dcam-reset-on-fail | ||
one-video-stream | ||
set-output-trigger | ||
set-roi | ||
) | ||
|
||
foreach(name ${tests}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
//! Test: Runs through setting up acquiring from a sub-rectangle of the sensor | ||
#include "acquire.h" | ||
#include "device/hal/device.manager.h" | ||
#include "device/props/components.h" | ||
#include "logger.h" | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#define L (aq_logger) | ||
#define LOG(...) L(0, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) | ||
#define ERR(...) L(1, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) | ||
#define CHECK(e) \ | ||
do { \ | ||
if (!(e)) { \ | ||
ERR("Expression evaluated as false: " #e); \ | ||
goto Error; \ | ||
} \ | ||
} while (0) | ||
#define DEVOK(e) CHECK(Device_Ok == (e)) | ||
#define OK(e) CHECK(AcquireStatus_Ok == (e)) | ||
|
||
#define countof(e) (sizeof(e) / sizeof(*(e))) | ||
|
||
void | ||
reporter(int is_error, | ||
const char* file, | ||
int line, | ||
const char* function, | ||
const char* msg) | ||
{ | ||
fprintf(is_error ? stderr : stdout, | ||
"%s%s(%d) - %s: %s\n", | ||
is_error ? "ERROR " : "", | ||
file, | ||
line, | ||
function, | ||
msg); | ||
} | ||
|
||
int | ||
setup(AcquireRuntime* runtime) | ||
{ | ||
AcquireProperties props = {}; | ||
|
||
const DeviceManager* dm = 0; | ||
CHECK(dm = acquire_device_manager(runtime)); | ||
|
||
#define SIZED(s) s, sizeof(s) - 1 | ||
DEVOK(device_manager_select(dm, | ||
DeviceKind_Camera, | ||
SIZED("Hamamatsu C15440-20UP.*"), | ||
&props.video[0].camera.identifier)); | ||
DEVOK(device_manager_select(dm, | ||
DeviceKind_Storage, | ||
SIZED("Trash"), | ||
&props.video[0].storage.identifier)); | ||
#undef SIZED | ||
|
||
props.video[0].max_frame_count = 10; | ||
props.video[0].camera.settings.shape = { .x = 1700, .y = 512 }; | ||
props.video[0].camera.settings.offset = { .x = 302, .y = 896 }; | ||
OK(acquire_configure(runtime, &props)); | ||
// Expect that the roi is what we intended. | ||
CHECK(props.video[0].camera.settings.shape.x == 1700); | ||
CHECK(props.video[0].camera.settings.shape.y == 512); | ||
CHECK(props.video[0].camera.settings.offset.x == 302); | ||
CHECK(props.video[0].camera.settings.offset.y == 896); | ||
return 1; | ||
Error: | ||
return 0; | ||
} | ||
|
||
int | ||
main() | ||
{ | ||
int ecode = 0; | ||
AcquireRuntime* runtime = 0; | ||
CHECK(runtime = acquire_init(reporter)); | ||
CHECK(setup(runtime)); | ||
OK(acquire_start(runtime)); | ||
OK(acquire_stop(runtime)); | ||
Finalize: | ||
acquire_shutdown(runtime); | ||
return ecode; | ||
Error: | ||
ecode = 1; | ||
goto Finalize; | ||
} |