-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #85 adds test, updates changelog Changes the ROI setting procedure so it's more robust: 1. Set offset to 0, so size can have full range of sensor. 2. Set the size 3. Set the offset Sometimes the offset has to be divisible by 4. When setting a parameter that is not appropriately divisible, the call just fails with an invalid parameter which is not very helpful. Fortunately, when running in "progressive" mode (the default for light-sheet), there are fewer restrictions. I'm not exactly sure how to query the restrictions, so the approach for this PR is to make sure we're setting the mode early.
- Loading branch information
Showing
5 changed files
with
130 additions
and
13 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
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,99 @@ | ||
//! 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 EXPECT(e, ...) \ | ||
do { \ | ||
if (!(e)) { \ | ||
ERR(__VA_ARGS__); \ | ||
goto Error; \ | ||
} \ | ||
} while (0) | ||
#define CHECK(e) EXPECT(e, "Expression evaluated as false: %s", #e) | ||
#define DEVOK(e) CHECK(Device_Ok == (e)) | ||
#define OK(e) CHECK(AcquireStatus_Ok == (e)) | ||
|
||
/// Check that a==b | ||
/// example: `ASSERT_EQ(int,"%d",42,meaning_of_life())` | ||
#define ASSERT_EQ(T, fmt, a, b) \ | ||
do { \ | ||
T a_ = (T)(a); \ | ||
T b_ = (T)(b); \ | ||
EXPECT(a_ == b_, "Expected %s==%s but " fmt "!=" fmt, #a, #b, a_, b_); \ | ||
} while (0) | ||
|
||
#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 = 304, .y = 896 }; | ||
OK(acquire_configure(runtime, &props)); | ||
// Expect that the roi is what we intended. | ||
|
||
ASSERT_EQ(int, "%d", props.video[0].camera.settings.shape.x, 1700); | ||
ASSERT_EQ(int, "%d", props.video[0].camera.settings.shape.y, 512); | ||
ASSERT_EQ(int, "%d", props.video[0].camera.settings.offset.x, 304); | ||
ASSERT_EQ(int, "%d", 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; | ||
} |