Gazebo | Ignition | Community
Ask Your Question

What is the mechanism of "OnNewFrame" in CameraPlugin??

asked 2018-10-25 15:42:11 -0600

Whyamihere gravatar image

I investigated into the source code but did not understand how it works, especially confused about how the arguments are passed into the function. I only found these cues. I understand it as some callback function but where are the values of placeholders come from?

private: event::ConnectionPtr newFrameConnection;
this->newFrameConnection = this->camera->ConnectNewImageFrame(
std::bind(&CameraPlugin::OnNewFrame, this,
        std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
        std::placeholders::_4, std::placeholders::_5));
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-11-02 08:30:06 -0600

wentz gravatar image

As you said its a callback function that is called every time a new frame is rendered.

The callback function CameraPlugin::OnNewFrame can get up to 5 Parameters. The values come directly from the Event (as far as i know). A typical callback will look like this:

void CameraEffectPlugin::OnNewFrame(const unsigned char *_image,
                          unsigned int /*_width*/,
                          unsigned int /*_height*/,
                          unsigned int /*_depth*/,
                          const std::string &/*_format*/)
// some code here
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-10-25 15:42:11 -0600

Seen: 1,629 times

Last updated: Nov 02 '18