Skip to content

Instantly share code, notes, and snippets.

View facontidavide's full-sized avatar
🤓
Developing

Davide Faconti facontidavide

🤓
Developing
View GitHub Profile
@facontidavide
facontidavide / benchmark_pcl_filter.cpp
Last active January 10, 2020 11:02
Show how horribly slow is pcl::ConditionalRemoval
#include <benchmark/benchmark.h>
#include <pcl/common/centroid.h>
#include <pcl/common/common.h>
#include <pcl/filters/conditional_removal.h>
#include <pcl/io/pcd_io.h>
#include <pcl/pcl_base.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
using namespace pcl;
@facontidavide
facontidavide / benchmark_scripting.cpp
Last active February 11, 2020 08:29
Lua vs QT JS
#include <iostream>
#include <QJSEngine>
#include "sol.hpp" //https://github.com/ThePhD/sol2
#include <benchmark/benchmark.h>
static void QmlFunction(benchmark::State& state) {
QJSEngine js;
js.evaluate("function calc(time, value){ return value*2 }");
QJSValue func = js.evaluate("calc");
@facontidavide
facontidavide / nano_serialization.hpp
Created January 20, 2021 18:54
Not much worse than boost::serialization
struct SizeStream{
unsigned size;
SizeStream(): size(0) {}
template <typename T>
typename std::enable_if<std::is_arithmetic<T>::value, SizeStream&>::type
operator <<(T& op)
{
size += sizeof(op);
@facontidavide
facontidavide / string_ref_sso.h
Last active November 18, 2021 03:33
Unmutable, string reference with "small object optimization".
/**
* @brief Super simple, unmutable, string_view with
* small string optimization.
* If the string is 15 bytes or less, it is copied, otherwise,
* StringRef stores a not-owning reference.
*/
class StringRef
{
private:
@facontidavide
facontidavide / rosPointCloud2ToPCL.hpp
Last active July 5, 2024 13:22
Drop in replacement for pcl::fromROSMsg
# include <pcl_conversions/pcl_conversions.h>
namespace pcl_df
{
// Usage: substitute pcl::fromROSMsg with pcl_df::fromROSMsg in your code and you have done.
// You should experience a considerable speedup.
template<typename T>
void fromROSMsg(const sensor_msgs::PointCloud2 &cloud, pcl::PointCloud<T> &pcl_cloud)
@facontidavide
facontidavide / point_converter.hpp
Last active June 19, 2024 01:18
Convert any point 3D from one type to another.
#include <type_traits>
// Magically converts any representation of a point in 3D
// (type with x, y and z) to another one. Works with:
//
// - pcl::PointXYZ, pcl::PointXYZI, pcl::PointXYZRGB, etc
// - Eigen::Vector3d, Eigen::Vector3f
// - custom type with x,y,z fields.
// - arrays or vectors with 3 elements.