Skip to content

Instantly share code, notes, and snippets.

View YoshiRi's full-sized avatar

Yoshi Ri YoshiRi

  • Shinagawa, Tokyo, Japan
View GitHub Profile
@YoshiRi
YoshiRi / ORB_matching.cpp
Created August 31, 2017 22:46
Normal ORB matcher in cpp and choosing good pair using stereo constraint
// Look at https://github.com/vonzhou/opencv/blob/master/image-search/orb.cpp
std::vector<cv::DMatch> ratio_test(std::vector< std::vector<cv::DMatch> > matches12, double ratio, std::vector<cv::KeyPoint> kpl, std::vector<cv::KeyPoint> kpr){
std::vector<cv::DMatch> good_matches;
for(int i = 0; i < matches12.size(); i++){
if(abs(kpl[matches12[i][0].queryIdx].pt.y - kpr[matches12[i][0].trainIdx].pt.y ) < 1){ // in the same line
if(matches12[i][0].distance < ratio * matches12[i][1].distance){
good_matches.push_back(matches12[i][0]);
}
}
}
@YoshiRi
YoshiRi / Stereo_match.cpp
Created August 31, 2017 22:45
get rectified image and put disparity image
// for image processing
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/ximgproc/disparity_filter.hpp"
#include <stdio.h>
#include <stdlib.h>
@YoshiRi
YoshiRi / Publish_stereo_rectimg.cpp
Last active August 31, 2017 04:49
Subscribe stereo left and right image and calibration information to publish rectified image
/* Author: Yoshi Ri @ Univ of Tokyo
* 2017 Aug 30
*
* Subscribing stereo camera image and camera info to get rectified image
*/
#include "ros/ros.h"
#include "sensor_msgs/Imu.h"
#include <iostream>
#include <boost/numeric/ublas/vector.hpp>
@YoshiRi
YoshiRi / Rectification.py
Created August 30, 2017 03:04
two single camera calibration file to get rectification and new projection matrix
import numpy as np
#D1 = [-0.35002811852321858, 0.096534651810849512, 0.0, 0.0, 0.000000]
#D2 = [-0.36311895125549826, 0.10890311353734204, 0.0, 0.0, 0.000000]
K1 = np.array([ 439.65213495954725,0,306.67821191917398,0,436.73222033708959,245.79237261646784,0,0,1]).reshape(3,3)
K2 = np.array([ 437.00346198880374,0,324.72266880648021,0,434.00126234994462,236.08291224903141,0,0,1]).reshape(3,3)
R1 = np.array([1.0,0,0, 0,1.0,0, 0,0,1.0 ]).reshape(3,3)
R2 = np.array([0.9999669439878518,-0.001850056106487306,-0.0079175895321455282, 0.0018719784959910215,0.99999443266408283,0.002762306527137064, 0.007912435030206437,-0.0027770367736432208,0.99996484010121622 ]).reshape(3,3)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 24 22:45:15 2017
@author: yoshi
"""
import cv2
import numpy as np
# -*- coding: utf-8 -*-
# largely from here
# http://russeng.hatenablog.jp/entry/2015/06/16/004704
import numpy
import cv2
# get file name efficiently
from glob import glob
def main():
@YoshiRi
YoshiRi / facerecog.py
Last active June 22, 2017 16:46
face recognizing for static image
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 23 00:05:14 2017
@author: ossyaritoori
"""
#coding: utf-8
@YoshiRi
YoshiRi / beamer_temp.sty
Last active May 2, 2017 17:29
Beamer Template Package
% 印刷時のサイズ調整?
\AtBeginDvi{\special{pdf:tounicode 90ms-RKSJ-UCS2}}
%%%%% 和文用 %%%%%
\usepackage{bxdpx-beamer}
\usepackage{pxjahyper} % PDF目次文字化け回避(platexでは不要)
\usepackage{minijs}%和文用
%%%%% スライドの見た目 %%%%%
%% data
xhat = [ 1 2 3 4 1 2 3 4 -1 -2 -3 -4 -1 -2 -3 -4].';
yhat = [ 1 2 3 4 -1 -2 -3 -4 1 2 3 4 -1 -2 -3 -4].';
phat = [1 2 1 2 -1 5]; % a,b,c,d,e,f
Noise = 5*randn(16,1);
syms x y z
p = sym('p',[ 1 6]);
@YoshiRi
YoshiRi / MutualInformation.m
Last active August 16, 2017 00:22
Calculations of Mutual Information between 2 image
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 2015 10/5 Yoshi R @ Univ. Tokyo
% input : 2 image with same size, grad:tone of image
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function mu = MutualInformation(img1,img2, grad)
if(~(size(img1)==size(img2)))
error('IMG size is differnt!');
end