Can I convert a sensor_msgs::Pointcloud to pcl::pointcloud - ros

Can I convert sensor_msgs::Pointcloud to pcl::pointcloud directly or I need to convert sensor_msgs::Pointcloud to sensor_msgs::Pointcloud2 before converting it to pcl::pointcloud?

As far as I understood it PCL can only work with sensor_msgs::PointCloud2 directly. ros_pcl.
U can use a converter as the middle-man between your pcl node and your publisher node. How to convert sensor_msgs::pointcloud to sensor_msgs::pointcloud2
or
If possible use sensor_msgs/PointCloud2
Take a look at: laser-scan-multi-merger it can be used to convert only one laser-scan topic aswell and directly converts it to PointCloud2.
The pass through filter can be done on the pcl::PointCloud side aswell no?

Related

How to implement a json decoder which doesn't convert numerics to double?

When I call json.decode on financial data returned from a server, I would like to either convert my numerics to decimal (pub.dev package) (or even leave them as strings so I can manually do that later). Everything else I would like to be converted as normal
There's a reviver callback which is passed to _parseJson(), but I can't find the implementation of this external function to study.
Update:
Looks like reviver() is too late: basic conversion has already happened by here and doubles get passed in. Is there any alternative callback that can be used?
I'd use the jsontool package (disclaimer: I wrote it, so obviously that's what I'd turn to first).
It's a low-level JSON processor which allows you (and requires you) to take control of the processing.
It has an example where it parses numbers into BigInts. You could probably adapt that to use Decimal instead.

How to change mlmultiarray to string

I am using a CoreML converted from a TensorFlow model for iOS. When I converted, the output is mlmultiarray, instead of the expected dictionary and string types.
Thus, the output would not be readable at all.
How would you fix this?
Thanks!
When you convert the model from TF to Core ML, you need to tell the converter this is a classifier. The easiest way to do this is to provide a text file (or array) containing the class labels when you run the converter.

What interpolation methods used in cv::cvtColor() demosaicing

I would like to reproduce the cv::cvtColor() function that converts a raw Bayer image into an RGB image. There are several different ways like COLOR_BayerBG2BGR, or COLOR_BayerBG2BGR_VNG, and COLOR_BayerBG2BGR_EA. However, I can not find any information on what interpolation method each of those approaches uses. There should be some references to publications or patents. Anyone knows?
OpenCV, as the name already suggests, is open source. Just read the source code if you are interested in what is happening under the hood. Or copy it if you want to "reproduce" the function...
https://github.com/opencv/opencv
Usually its just the average of the neighbouring values. what fancy interpolation method would you expect?

Matching two images using VideoGrabber with OpenCV

I' trying to match one image from VideoGrabber and another image that is on disk.
I'm following this tutorial.
The problem is that it uses the function imread, which takes a string (path of the file), incompatible with VideGrabber type.
How can I convert a VideoGrabber from openframeworks data type to opencv mat type?
Is this what you want?
ofVideoGrabber vidGrabber;
...
cv::Mat frame(vidGrabber.getHeight(), vidGrabber.getWidth(), CV_8UC3, vidGrabber.getPixels());
I am not sure what format uses to pack pixels, OpenCV uses BGR interleaved channels, you may have to swap pixels around.
Ok, it seems to be a specific question about openframworks. You can use the wonderful addon ofxCv fro Kyle, it is specifically for an alternative use of opencv library inside openframeworks.
in ofxCv you can find methods such as toCv for converting openframeworks types to opencv, and toOf, for the inverse process. Have a look, it is well documented, with a lot of examples, and well designed.
Not exactly sure what difficulty you have with string versus array char[]. Array of chars can be converted to string like this:
char myarray[ ] = "my_file_name";
string str(myarray);

process a signal from a .wav and turn it into binary data

I recorded a radio signal into a .wav, I can open it in audacity and see that there is binary data encoded using a certain algorithm. Does anyone know of a way to process the signal that is contained within the .wav? so that i can extract the binary data from it?
I know that I need to know the encoding algorithm for it to work properly, anyone know of any program that does something like that?
Thanks
sox will convert most audio formats to most other audio formats - including raw binary.
The .wav format is generally very simple and wav files usually don't have compressed data. It's quite feasible to parse it yourself, but much easier to use something already made. So the short answer is to find something that can read wav files in your language of choice.
Here's an example in Python, using the wave module:
import wave
w = wave.open("myfile.wav", "rb")
binary_data = w.readframes(w.getnframes())
w.close()
Now where you go depends on what else you want to do. binary_data is now a python string of the raw bytes. If you just want to chop this and repackage it, it's probably easiest to leave it in this form. If you want to manipulated the data, such as scale it, interpolate, filter, etc, you would probably want to convert this into a sequence of numbers, and for this, in Python, you'd want to convert it to a numpy array. You could do this yourself using the struct module, which is for interpreting strings as packed binary data, or you could just have read in the data using scipy.io.wave module which does this for you. As you can see, most of this becomes fairly language dependent quickly.

Resources