Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Applications] Show detected markers in video and live mode #33

Merged
merged 34 commits into from
Sep 7, 2016

Conversation

simogasp
Copy link
Member

@simogasp simogasp commented Sep 3, 2016

Modified the detection.cpp example so that you can see the detected markers on a UI (similar to appCutie) when using a video (and I added the support for webcams)

  • some code cleaning
  • no more saving all the video frames before processing them
  • added .mov as video format
  • support for live acquisition (eg usb webcam) with opencv
  • two modes, live (default) and debug (it waits for a key to be pressed to move forward); switch from one to another by pressing 'l'/'L' (live) and 'd'/'D' (debug)

@simogasp simogasp changed the title Show detected markers in video and live mode [Applications] Show detected markers in video and live mode Sep 3, 2016
@@ -116,7 +116,7 @@ void CmdLine::usage( const char* const argv0 )
" [--use-cuda]\n"
" [--parallel <n>]\n"
"\n"
" <imgpath> - path to an image (JPG, PNG) or video\n"
" <imgpath> - path to an image (JPG, PNG) or video(avi, mov) or camera index for live capture (0, 1...)\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space video(avi, mov)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

cv::cvtColor(imgGray, frame, cv::COLOR_GRAY2BGRA);

drawMarkers(markers, frame);
cv::imshow(windowName, frame);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a UI should be an option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? :-)

*/
bool isInteger(std::string s)
{
std::regex e("^-?\\d+");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sadly crashes at runtime with gcc4.8 (ubuntu 14.04.05) as regex apparently are not fully supported in that version. I'll find a workaround...

Copy link
Member

@zvrba zvrba Sep 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not going to have 10 cameras anytime soon so replace it with s.size()==1 && std::isdigit(s[0]).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah maybe your right, it was a bit overkilling it... ;-)

*/
void drawMarkers(const boost::ptr_list<CCTag> &markers, cv::Mat &image)
{
BOOST_FOREACH(const cctag::CCTag & marker, markers)
Copy link
Member

@zvrba zvrba Sep 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In C++11 there's no reason whatsoever to use BOOST_FOREACH. Use for (const auto& marker : markers) { ... }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#endif // WITH_CUDA

bfs::path myPath( cmdline._filename );
bfs::path myPath(bfs::absolute(cmdline._filename));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bfs ?! Be consistent, either use bfs or boost::filesystem everywhere, but don't mix them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

frames.push_back( imgGray );
}
std::cerr << "Done. Now processing." << std::endl;
boost::timer t;
Copy link
Member

@zvrba zvrba Sep 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the timer be inside the for-loop if the meaning is to measure per-frame time? You should also instantiate it just before calling detection. Could also upgrade to use the new timer implementation: http://www.boost.org/doc/libs/1_49_0/libs/timer/doc/cpu_timers.html

In any case, it seems to be unused, so just remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i just forgot to remove it from the previous version, there is already a timer inside detection

@zvrba zvrba merged commit a52a381 into develop Sep 7, 2016
@zvrba zvrba deleted the videoApplication branch September 7, 2016 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants