Skip to content

Instantly share code, notes, and snippets.

View stfuchs's full-sized avatar

Steffen Fuchs stfuchs

  • Zebra Technologies
  • San Jose, CA
View GitHub Profile
@stfuchs
stfuchs / rotate_matrix.cpp
Last active October 6, 2017 09:06
Rotate image matrix clockwise inplace
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
/*
* Rotate square matrix by 90 deg clock wise.
*/
template<typename T>
bool rotateMatrix(std::vector< std::vector<T> >& mat)
import sys
from collections import defaultdict, deque
INVALID = "Invalid"
class Record(object):
SOUND = "neigh"
def __init__(self):
self._next = 0
@stfuchs
stfuchs / eigen_cheatsheet.cpp
Last active July 12, 2017 15:37
Eigen Geometry Cheat Sheet
#include <Eigen/Geometry>
int main(int argc, char** argv)
{
Eigen::Quaterniond q1(0, 0, 0, 1.);
Eigen::Vector3d t1(1., 0, 1.);
Eigen::Vector3d p1 = q1*Eigen::Vector3d(0,0,0) + t1;
//Isometry if only rotation and translation components
Eigen::Isometry3d tf = Eigen::Translation3d(t1) * q1;
Eigen::Affine3d tf_affine = tf;
#include <camera_info_manager/camera_info_manager.h>
ros::NodeHandle nh("~");
camera_info_manager::CameraInfoManager mgr(nh);
mgr.setCameraName("camera");
mgr.loadCameraInfo("file://my/camera_info.yaml");
sensor_msgs::CameraInfo info = mgr.getCameraInfo();
@stfuchs
stfuchs / hex2bgr.py
Created December 16, 2015 17:30
snippet to convert hex color list to cv::Scalar vector(bgr)
# example color list:
c = """#e41a1c
#377eb8
#4daf4a
#984ea3
#ff7f00
#ffff33
#a65628
#f781bf
#999999"""
bool
compare (int idx1, int idx2) const
{
bool dist_ok;
if(this->depth_dependent_)
{
Eigen::Vector3f vec = input_->points[idx1].getVector3fMap ();
float z = vec.dot (this->z_axis_);
dist_ok = (fabs ((*plane_coeff_d_)[idx1] - (*plane_coeff_d_)[idx2]) < distance_threshold_ * z * z);
}