mirror of
https://github.com/open-mmlab/mmdeploy.git
synced 2025-01-14 08:09:43 +08:00
[Fix] Add an option to flip webcam inputs for pose tracker demo (#1725)
(cherry picked from commit 5de0ecfcaf716bc919f5e4ee8661ed8b6b34a709)
This commit is contained in:
parent
682cb79bc5
commit
2731b61abd
@ -14,6 +14,7 @@ DEFINE_string(device, "cpu", "Device name, e.g. \"cpu\", \"cuda\"");
|
|||||||
DEFINE_string(output, "", "Output video path or format string");
|
DEFINE_string(output, "", "Output video path or format string");
|
||||||
|
|
||||||
DEFINE_int32(output_size, 0, "Long-edge of output frames");
|
DEFINE_int32(output_size, 0, "Long-edge of output frames");
|
||||||
|
DEFINE_int32(flip, 0, "Set to 1 for flipping the input horizontally");
|
||||||
DEFINE_int32(show, 1, "Delay passed to `cv::waitKey` when using `cv::imshow`; -1: disable");
|
DEFINE_int32(show, 1, "Delay passed to `cv::waitKey` when using `cv::imshow`; -1: disable");
|
||||||
|
|
||||||
DEFINE_string(skeleton, "coco", R"(Path to skeleton data or name of predefined skeletons: "coco")");
|
DEFINE_string(skeleton, "coco", R"(Path to skeleton data or name of predefined skeletons: "coco")");
|
||||||
@ -38,7 +39,7 @@ int main(int argc, char* argv[]) {
|
|||||||
// create a tracker state for each video
|
// create a tracker state for each video
|
||||||
mmdeploy::PoseTracker::State state = tracker.CreateState(params);
|
mmdeploy::PoseTracker::State state = tracker.CreateState(params);
|
||||||
|
|
||||||
utils::mediaio::Input input(ARGS_input);
|
utils::mediaio::Input input(ARGS_input, FLAGS_flip);
|
||||||
utils::mediaio::Output output(FLAGS_output, FLAGS_show);
|
utils::mediaio::Output output(FLAGS_output, FLAGS_show);
|
||||||
|
|
||||||
utils::Visualize v(FLAGS_output_size);
|
utils::Visualize v(FLAGS_output_size);
|
||||||
@ -59,7 +60,7 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
// write to output stream
|
// write to output stream
|
||||||
if (!output.write(sess.get())) {
|
if (!output.write(sess.get())) {
|
||||||
// user requested exit by pressing 'q'
|
// user requested exit by pressing ESC
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,8 +154,8 @@ class BatchInputIterator {
|
|||||||
|
|
||||||
class Input {
|
class Input {
|
||||||
public:
|
public:
|
||||||
explicit Input(const std::string& path, MediaType type = MediaType::kUnknown)
|
explicit Input(const std::string& path, bool flip = false, MediaType type = MediaType::kUnknown)
|
||||||
: path_(path), type_(type) {
|
: path_(path), flip_(flip), type_(type) {
|
||||||
if (type_ == MediaType::kUnknown) {
|
if (type_ == MediaType::kUnknown) {
|
||||||
auto ext = detail::get_extension(path);
|
auto ext = detail::get_extension(path);
|
||||||
if (detail::is_image(ext)) {
|
if (detail::is_image(ext)) {
|
||||||
@ -212,6 +212,9 @@ class Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (flip_ && !img.empty()) {
|
||||||
|
cv::flip(img, img, 1);
|
||||||
|
}
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,8 +273,9 @@ class Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MediaType type_{MediaType::kUnknown};
|
|
||||||
std::string path_;
|
std::string path_;
|
||||||
|
bool flip_{};
|
||||||
|
MediaType type_{MediaType::kUnknown};
|
||||||
std::vector<std::string> items_;
|
std::vector<std::string> items_;
|
||||||
cv::VideoCapture cap_;
|
cv::VideoCapture cap_;
|
||||||
size_t index_{};
|
size_t index_{};
|
||||||
@ -350,7 +354,7 @@ class Output {
|
|||||||
}
|
}
|
||||||
if (show_ >= 0) {
|
if (show_ >= 0) {
|
||||||
cv::imshow("", frame);
|
cv::imshow("", frame);
|
||||||
exit = cv::waitKey(show_) == 'q';
|
exit = cv::waitKey(show_) == 27; // ESC
|
||||||
}
|
}
|
||||||
++frame_id_;
|
++frame_id_;
|
||||||
return !exit;
|
return !exit;
|
||||||
@ -385,4 +389,5 @@ OutputIterator& OutputIterator::operator=(const cv::Mat& frame) {
|
|||||||
|
|
||||||
} // namespace mediaio
|
} // namespace mediaio
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
||||||
#endif // MMDEPLOY_MEDIAIO_H
|
#endif // MMDEPLOY_MEDIAIO_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user