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

Use kYUV422 images to increase the acquisition frequency #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/converters/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
*/
#include <cv_bridge/cv_bridge.h>

/*
* CV includes
*/
#include <opencv2/imgproc/imgproc.hpp>

/*
* BOOST includes
*/
Expand Down Expand Up @@ -126,7 +121,7 @@ CameraConverter::CameraConverter( const std::string& name, const float& frequenc
camera_source_(camera_source),
resolution_(resolution),
// change in case of depth camera
colorspace_( (camera_source_!=AL::kDepthCamera)?AL::kRGBColorSpace:AL::kRawDepthColorSpace ),
colorspace_( (camera_source_!=AL::kDepthCamera)?AL::kYUV422ColorSpace:AL::kRawDepthColorSpace ),
Copy link
Member

Choose a reason for hiding this comment

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

Can you please keep RGB by default?

msg_colorspace_( (camera_source_!=AL::kDepthCamera)?"rgb8":"16UC1" ),
cv_mat_type_( (camera_source_!=AL::kDepthCamera)?CV_8UC3:CV_16U ),
camera_info_( camera_info_definitions::getCameraInfo(camera_source, resolution) )
Expand Down Expand Up @@ -211,8 +206,15 @@ void CameraConverter::callAll( const std::vector<message_actions::MessageAction>
}

// Create a cv::Mat of the right dimensions
cv::Mat cv_img(image.height, image.width, cv_mat_type_, image.buffer);
msg_ = cv_bridge::CvImage(std_msgs::Header(), msg_colorspace_, cv_img).toImageMsg();
if (colorspace_ == AL::kYUV422ColorSpace)
{
cv::Mat cv_YUV(image.height, image.width, CV_8UC2, image.buffer);
cvtColor(cv_YUV, cv_img_, CV_YUV2RGB_YUYV);
}
else
cv_img_= cv::Mat(image.height, image.width, cv_mat_type_,image.buffer);

msg_ = cv_bridge::CvImage(std_msgs::Header(), msg_colorspace_, cv_img_).toImageMsg();
msg_->header.frame_id = msg_frameid_;

msg_->header.stamp = ros::Time::now();
Expand Down
6 changes: 6 additions & 0 deletions src/converters/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
*/
#include <image_transport/image_transport.h>

/*
* CV includes
*/
#include <opencv2/imgproc/imgproc.hpp>

namespace naoqi
{
namespace converter
Expand Down Expand Up @@ -64,6 +69,7 @@ class CameraConverter : public BaseConverter<CameraConverter>
// goes along with colorspace_
std::string msg_colorspace_;
int cv_mat_type_;
cv::Mat cv_img_;
// msg frame id
std::string msg_frameid_;
sensor_msgs::CameraInfo camera_info_;
Expand Down