Persist rover observation configuration and calibrate Insta360 panorama
This commit is contained in:
@@ -93,6 +93,18 @@ def test_discovery_never_selects_first_of_multiple_cameras(library):
|
||||
assert library.test_count(0) == 0 and library.test_count(2) == 2
|
||||
|
||||
|
||||
def test_details_include_session_identity_and_optics_without_starting_preview(camera):
|
||||
api, _ = camera
|
||||
result = call(camera, 1)["result"]
|
||||
assert result["serial"] == "SYNTHETIC-X4"
|
||||
assert len(result["preview_calibration"]["offsets"]) == 1
|
||||
assert result["preview_calibration"]["crop"] == {
|
||||
"source_width": 1920, "source_height": 960,
|
||||
"width": 1920, "height": 960, "x": 0, "y": 0,
|
||||
}
|
||||
assert api.test_count(3) == 0 and api.test_count(6) == 0
|
||||
|
||||
|
||||
def test_preview_stop_and_close_do_not_stop_recording(camera):
|
||||
api, handle = camera
|
||||
assert call(camera, 6)["state"] == "complete"
|
||||
@@ -179,6 +191,20 @@ def test_early_camera_stop_notification_wins_over_start_acknowledgement(camera):
|
||||
assert api.test_count(4) == 1
|
||||
|
||||
|
||||
def test_unavailable_calibration_preserves_camera_control(library):
|
||||
for mode in (1, 2):
|
||||
library.test_calibration(mode)
|
||||
handle = library.mc_x4_open(b"SYNTHETIC-X4", b"/unused")
|
||||
assert handle
|
||||
try:
|
||||
result = call((library, handle), 1)["result"]
|
||||
assert result["serial"] == "SYNTHETIC-X4"
|
||||
assert result["preview_calibration"] is None
|
||||
assert library.test_count(3) == 0 and library.test_count(6) == 0
|
||||
finally:
|
||||
library.mc_x4_close(handle)
|
||||
|
||||
|
||||
class TestNativeBridge(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
@@ -10,7 +10,7 @@ int discovered = 1, opens = 0, closes = 0, freed = 0, writes = 0;
|
||||
int record_starts = 0, record_stops = 0, previews = 0, preview_stops = 0;
|
||||
bool recording = false, start_ack = true, preview_ack = true, connected = true;
|
||||
bool stop_before_ack = false;
|
||||
int function_mode = 7;
|
||||
int function_mode = 7, calibration_mode = 0;
|
||||
std::shared_ptr<ins_camera::StreamDelegate> delegate;
|
||||
ins_camera::CaptureStateCallBack capture_callback;
|
||||
std::shared_ptr<ins_camera::CaptureSettings> capture;
|
||||
@@ -19,6 +19,21 @@ std::shared_ptr<ins_camera::ExposureSettings> exposure;
|
||||
|
||||
namespace ins_camera {
|
||||
class CameraImpl {};
|
||||
struct PreviewParam::Impl {};
|
||||
PreviewParam::PreviewParam() = default;
|
||||
PreviewParam::~PreviewParam() = default;
|
||||
PreviewParam::PreviewParam(PreviewParam&&) noexcept = default;
|
||||
PreviewParam& PreviewParam::operator=(PreviewParam&&) noexcept = default;
|
||||
size_t PreviewParam::GetCalibrationCount() const { if (calibration_mode == 1) throw std::runtime_error("unavailable"); return calibration_mode == 2 ? 5 : 1; }
|
||||
std::string PreviewParam::GetCalibration(size_t) const { return "2_480_480_480_0_0_0_480_1440_480_0_0_0_1920_960_0"; }
|
||||
uint32_t PreviewParam::GetCropSrcWidth() const { return 1920; }
|
||||
uint32_t PreviewParam::GetCropSrcHeight() const { return 960; }
|
||||
uint32_t PreviewParam::GetCropDstWidth() const { return 1920; }
|
||||
uint32_t PreviewParam::GetCropDstHeight() const { return 960; }
|
||||
int32_t PreviewParam::GetCropOffsetX() const { return 0; }
|
||||
int32_t PreviewParam::GetCropOffsetY() const { return 0; }
|
||||
PreviewParam Camera::GetPreviewParam() const { return PreviewParam(); }
|
||||
|
||||
class ExposureSettingsPrivate {
|
||||
public:
|
||||
int iso = 100, ev = 0;
|
||||
@@ -109,13 +124,14 @@ void ExposureSettings::SetExposureMode(PhotographyOptions_ExposureMode value) {
|
||||
extern "C" {
|
||||
void test_reset() {
|
||||
discovered = 1; opens = closes = freed = writes = record_starts = record_stops = previews = preview_stops = 0;
|
||||
recording = stop_before_ack = false; connected = start_ack = preview_ack = true; function_mode = 7;
|
||||
recording = stop_before_ack = false; connected = start_ack = preview_ack = true; function_mode = 7; calibration_mode = 0;
|
||||
delegate.reset(); capture_callback = nullptr;
|
||||
capture = std::make_shared<ins_camera::CaptureSettings>(); exposure = std::make_shared<ins_camera::ExposureSettings>();
|
||||
}
|
||||
int test_count(int which) {
|
||||
switch (which) { case 0: return opens; case 1: return closes; case 2: return freed; case 3: return writes; case 4: return record_starts; case 5: return record_stops; case 6: return previews; case 7: return preview_stops; default: return -1; }
|
||||
}
|
||||
void test_calibration(int mode) { calibration_mode = mode; }
|
||||
void test_discovered(int count) { discovered = count; }
|
||||
void test_ack(int type, int value) { if (type == 0) start_ack = value; else if (type == 1) preview_ack = value; else stop_before_ack = value; }
|
||||
void test_connected(int value) { connected = value; }
|
||||
|
||||
Reference in New Issue
Block a user