Comments (4)
Thank you!
That was the problem.
I think it is fixed now.
from o3d3xx-ros.
To do what you want, you just need to do something like:
cv::Mat xim, yim, zim;
std::vector<cv::Mat> channels(3);
cv::split(xyz, channels);
xim = channels[0];
yim = channels[1];
zim = channels[2];
Now each individual spatial plane of the image is available as a single channel image with the same number of rows, columns, and pixel depth (namely signed 16-bit integers) as the original 3-channel image.
Now, what I am suggesting above is what you should do. However, to answer one of your concerns above:
but by using this way we only get half of the pixels.
This is a result of (using your z-image plane as an example):
img_z.at<uchar>(row, col/2) = result;
The pixel depth is 16-bits not 8.
But again, your code is over complicating things. Use the above snippet I have posted in and you should be good to go.
from o3d3xx-ros.
Thanks for your reaction.
if i understand you correctly i can use it this way.
i stil get the wrong numbers. can it be that the image is being converted wrong from the topic ?
sorry for bothering you
// ROS
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <stdlib.h>
#include <std_msgs/String.h>
// OpenCV
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
namespace enc = sensor_msgs::image_encodings;
// Read message
void read_image(const sensor_msgs::ImagePtr& msg)
{
// Read image
cv_bridge::CvImagePtr img_ptr;
try
{
img_ptr = cv_bridge::toCvCopy(msg, enc::TYPE_16SC3);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
cv::Mat xim, yim, zim;
std::vector<cv::Mat> channels(3);
cv::split(img_ptr->image, channels);
xim = channels[0];
yim = channels[1];
zim = channels[2];
ROS_INFO("img %i",zim.at(89,34));
}
// Start and initialize the node
int main(int argc, char **argv)
{
// Initialize ros node
ros::init(argc, argv, "listener");
ros::NodeHandle nh;
// Subscribe to the topic
ros::Subscriber sub = nh.subscribe("o3d3xx/camera/xyz_image", 100, read_image);
// Wait for messages
ros::spin();
}
from o3d3xx-ros.
Two things:
First, you should change:
zim.at(89,34)
to
zim.at<std::int16_t>(89,34)
Second, be aware that the xyz_image
is in the same coordinate frame as the point cloud, namely x-forward, y-left, z-up. The only difference is that the data are sent as signed 16-bit ints in mm rather than 32-bit floats in meters as the point cloud does.
from o3d3xx-ros.
Related Issues (20)
- install issues test errors HOT 5
- SWTrigger Service doesn't return error codes HOT 3
- using mask to lower the amount of information to pc HOT 9
- catkin_make run_tests failure HOT 8
- Getting Libo3d3xx on Yocto HOT 5
- Unable to change SymmetryThreshold of Imager HOT 3
- Amplitude image scaling HOT 2
- Problem with nodes while launching ros HOT 4
- Private node handle for topics and services HOT 1
- Doubt on the dataframe HOT 2
- Time stamp on images incorrect HOT 7
- Incorporate filtering at a ROS node/driver level HOT 5
- Compiling o3d3xx-ros HOT 2
- -
- Can't find libopencv_core3.so.3.2 HOT 5
- Where on the physical camera is o3d3xx/camera_link located? HOT 2
- PointCloud<pcl::PointWithRange> range data HOT 3
- IFM 03X101 HOT 1
- crash
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from o3d3xx-ros.