Skip to content

Commit

Permalink
camera-manager: usage fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Julian Oes <[email protected]>
  • Loading branch information
julianoes committed Mar 7, 2024
1 parent 0a1c762 commit 17e3df7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
24 changes: 16 additions & 8 deletions camera-manager/siyi_camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Camera {
Res1280x720,
Res1920x1080,
Res2560x1440,
Res4096x2160,
Res3840x2160,
};

enum class Zoom {
Expand All @@ -96,8 +96,8 @@ class Camera {
}

[[nodiscard]] Resolution resolution() const {
if (_stream_settings.resolution_h == 1920 && _stream_settings.resolution_l == 4096) {
return Resolution::Res4096x2160;
if (_stream_settings.resolution_h == 1920 && _stream_settings.resolution_l == 3840) {
return Resolution::Res3840x2160;
} else if (_stream_settings.resolution_h == 1440 && _stream_settings.resolution_l == 2560) {
return Resolution::Res2560x1440;
} else if (_stream_settings.resolution_h == 1080 && _stream_settings.resolution_l == 1920) {
Expand Down Expand Up @@ -133,8 +133,8 @@ class Camera {
} else if (resolution == Resolution::Res2560x1440) {
set_stream_settings.resolution_l = 2560;
set_stream_settings.resolution_h = 1440;
} else if (resolution == Resolution::Res4096x2160) {
set_stream_settings.resolution_l = 4096;
} else if (resolution == Resolution::Res3840x2160) {
set_stream_settings.resolution_l = 3840;
set_stream_settings.resolution_h = 2160;
} else {
std::cerr << "resolution invalid\n";
Expand Down Expand Up @@ -268,13 +268,21 @@ class Camera {
return false;
}

_messager.send(_serializer.assemble_message(siyi::GetStreamSettings{}));
auto get_stream_settings = siyi::GetStreamSettings{};
get_stream_settings.stream_type = set_stream_settings.stream_type;
_messager.send(_serializer.assemble_message(get_stream_settings));
const auto maybe_stream_settings =
_deserializer.disassemble_message<siyi::AckGetStreamResolution>(_messager.receive());

if (maybe_stream_settings) {

_stream_settings = maybe_stream_settings.value();
switch (type) {
case Type::Recording:
_recording_settings = maybe_stream_settings.value();
break;
case Type::Stream:
_stream_settings = maybe_stream_settings.value();
break;
}
return true;
} else {
return false;
Expand Down
18 changes: 10 additions & 8 deletions camera-manager/siyi_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ void print_usage(const std::string_view& bin_name)
<< " take_picture Take a picture to SD card\n\n"
<< " toggle_recording Toggle start/stop video recording to SD card\n\n"
<< " gimbal_forward Set gimbal forward\n\n"
<< " zoom <option> Use zoom\n"
<< " Options:\n"
<< " - in (to start zooming in)\n"
<< " - out (to start zooming out)\n"
<< " - stop (to stop zooming)\n"
<< "\n"
<< " get <stream|recording> settings Show all settings for stream or recording\n\n"
<< "\n"
<< " set <stream|recording> resolution <option> Set stream resolution\n\n"
<< " Options:\n"
<< " - 720 (for 1280x720)\n"
<< " - 1080 (for 1920x1080)\n\n"
<< " - 1440 (for 2560x1440, recording only)\n\n"
<< " - 1080 (for 4096x1920, recording only)\n\n"
<< " - 1920 (for 3840x1920, recording only)\n\n"
<< " set <stream|recording> bitrate <option> Set stream bitrate\n"
<< " Options:\n"
<< " - 1m (for 1.5 Mbps, only available at 1280x720)\n"
Expand All @@ -29,11 +35,7 @@ void print_usage(const std::string_view& bin_name)
<< " Options:\n"
<< " - h264 (for H264)\n"
<< " - h265 (for H265/HVEC)\n"
<< " zoom <option> Use zoom\n"
<< " Options:\n"
<< " - in (to start zooming in)\n"
<< " - out (to start zooming out)\n"
<< " - stop (to stop zooming)\n";
<< "\n";
}

int main(int argc, char* argv[])
Expand Down Expand Up @@ -120,8 +122,8 @@ int main(int argc, char* argv[])

if (setting == "resolution") {
if (option == "1920") {
std::cout << "Set " << type_str << " resolution to 4096x2160..." << std::flush;
if (siyi_camera.set_resolution(type, siyi::Camera::Resolution::Res4096x2160)) {
std::cout << "Set " << type_str << " resolution to 3840x2160..." << std::flush;
if (siyi_camera.set_resolution(type, siyi::Camera::Resolution::Res3840x2160)) {
std::cout << "ok" << std::endl;
} else {
std::cout << "failed" << std::endl;
Expand Down

0 comments on commit 17e3df7

Please sign in to comment.