Clean up main()
This commit is contained in:
parent
2f4587e40a
commit
36e5d15400
1 changed files with 20 additions and 11 deletions
31
src/main.cpp
31
src/main.cpp
|
@ -1,6 +1,7 @@
|
||||||
#include "camera.hpp"
|
#include "camera.hpp"
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
|
# include <iomanip>
|
||||||
#endif
|
#endif
|
||||||
#include <opencv2/flann.hpp>
|
#include <opencv2/flann.hpp>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
@ -21,22 +22,30 @@ std::ostream& operator<< (std::ostream& stream, const FrameFormat& value) {
|
||||||
} //namespace mgs
|
} //namespace mgs
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
#if !defined(NDEBUG)
|
||||||
|
void print_supported_frame_formats (const mgs::Camera& cam) {
|
||||||
|
const auto curr_frame_size = cam.frame_size();
|
||||||
|
|
||||||
|
std::cout << "Supported frame formats:\n";
|
||||||
|
int count = 0;
|
||||||
|
for (const auto& size : cam.supported_frame_sizes()) {
|
||||||
|
std::cout << std::setw(2) << ++count << " - " << size;
|
||||||
|
|
||||||
|
if (curr_frame_size == size)
|
||||||
|
std::cout << " *";
|
||||||
|
std::cout << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} //unnamed namespace
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
try {
|
try {
|
||||||
mgs::Camera cam("/dev/video0", {}, false);
|
mgs::Camera cam("/dev/video0", {}, false);
|
||||||
cam.set_frame_size({1280, 720, MjpegFormat});
|
cam.set_frame_size({1280, 720, MjpegFormat});
|
||||||
std::cout << mgs::FrameFormat{1280, 720, MjpegFormat} << '\n';
|
|
||||||
|
|
||||||
#if !defined(NDEBUG)
|
print_supported_frame_formats(cam);
|
||||||
const auto curr_frame_size = cam.frame_size();
|
|
||||||
|
|
||||||
for (const auto& size : cam.supported_frame_sizes()) {
|
|
||||||
std::cout << size;
|
|
||||||
if (curr_frame_size == size)
|
|
||||||
std::cout << " *";
|
|
||||||
std::cout << '\n';
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
cam.start_streaming();
|
cam.start_streaming();
|
||||||
|
|
||||||
std::vector<char> my_frame;
|
std::vector<char> my_frame;
|
||||||
|
|
Loading…
Reference in a new issue