Skip to content

Instantly share code, notes, and snippets.

View wngreene's full-sized avatar

W. Nicholas Greene wngreene

View GitHub Profile
@wngreene
wngreene / ext_pose_example.cc
Last active February 20, 2016 21:47
lsd_tracker external pose as initial estimate
SE3 frame_to_kf_init = se3FromSim3(curr_tracking_ref_->keyframe->pose->getCamToWorld().inverse() *
sim3FromSE3(pose, 1.0));
frame_to_kf_init.translation() *= curr_tracking_ref_->keyframe->pose->getCamToWorld().scale();
SE3 frame_to_kf_upd = tracker_->trackFrame(curr_tracking_ref_.get(),
trackingNewFrame.get(),
frame_to_kf_init);
;; Flycheck.
(use-package flycheck
:ensure t
:config (progn (add-hook 'after-init-hook #'global-flycheck-mode)
(add-hook 'python-mode-hook (lambda ()
(flycheck-select-checker 'python-pylint)))
(setq-default flycheck-disabled-checkers '(c/c++-clang c/c++-gcc))))
;; Flycheck Google cpplint
(use-package flycheck-google-cpplint
// Project corners of image b into rectified camera.
std::vector<cv::Point2f> corners(4);
corners[0] = cv::Point2f(0.0f, 0.0f);
corners[1] = cv::Point2f(img_b.cols, 0.0f);
corners[2] = cv::Point2f(img_b.cols, img_b.rows);
corners[3] = cv::Point2f(0.0f, img_b.rows);
std::vector<cv::Point2f> new_corners(4);
Eigen::Quaternionf q_b_to_a(q_a.inverse() * q_b);
Eigen::Matrix3f P(K_b * q_b_to_a.toRotationMatrix() * K_b.inverse());
@wngreene
wngreene / tf2_lookup_example.cc
Created June 3, 2016 20:25
Example of how to equery tf for a transform.
// In header:
#include <tf2_ros/transform_listener.h>
std::shared_ptr<tf2_ros::TransformListener> tf_listener_;
tf2_ros::Buffer tf_buffer_;
// In constructor:
tf_listener_ =
std::make_shared<tf2_ros::TransformListener>(tf_buffer_);
@wngreene
wngreene / readlink_example.cc
Last active June 12, 2016 19:21
Example of using readlink to get directory of executable.
@wngreene
wngreene / defaulted_stuff.cc
Last active June 12, 2016 19:27
Example of use of default specifier that fails to compile.
/**
* \brief Class to represent a feature track.
*/
class FeatureTrack final {
public:
explicit FeatureTrack(const uint32_t id = 0, const uint32_t img_idx = 0,
const cv::Point2f& feat = cv::Point2f()) :
id(id),
pos(1, feat),
img(1, img_idx) {}
@wngreene
wngreene / example_plots.py
Last active June 28, 2016 16:27
Example plots using Matplotlib.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2015 Massachusetts Institute of Technology
"""Example plots using Matplotlib.
"""
import os
@wngreene
wngreene / ansi_color.el
Created September 23, 2016 18:06
Snippet to fix colors in emacs compile buffer.
;; ansi-color.
;; https://emacs.stackexchange.com/questions/8135/why-does-compilation-buffer-show-control-characters
(use-package ansi-color
:ensure t
:config (progn
(defun my/ansi-colorize-buffer ()
(let ((buffer-read-only nil))
(ansi-color-apply-on-region (point-min) (point-max))))
(add-hook 'compilation-filter-hook 'my/ansi-colorize-buffer)))
@wngreene
wngreene / script.py
Created October 27, 2016 20:42
Python script boilerplate.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
pass
if __name__ == '__main__':
main()
@wngreene
wngreene / udacity_cs344_hw2_kernel.cu
Created June 8, 2016 23:43
Udacity CS344 HW2 Kernel
// Homework 2
// Image Blurring
//
// In this homework we are blurring an image. To do this, imagine that we have
// a square array of weight values. For each pixel in the image, imagine that we
// overlay this square array of weights on top of the image such that the center
// of the weight array is aligned with the current pixel. To compute a blurred
// pixel value, we multiply each pair of numbers that line up. In other words, we
// multiply each weight with the pixel underneath it. Finally, we add up all of the
// multiplied numbers and assign that value to our output for the current pixel.