Skip to content

Instantly share code, notes, and snippets.

View masazdream's full-sized avatar

Masahiro I masazdream

View GitHub Profile
@masazdream
masazdream / Utils.hpp
Created February 15, 2014 09:01
Utils用のヘッダーファイル
/*
* Utils.h
*
* Created on: 2013/06/19
* Author: root
*/
#include <fstream>
#include <cassert>
#include <cv.h>
#include <sstream>
@masazdream
masazdream / fileopen.cpp
Created February 15, 2014 10:05
ifstreamでファイルを開くとき用
/**
* open file
*/
void OpenFile(ifstream& file, const char* file_list_path) {
file.open(file_list_path);
if (!file.is_open()) {
throw "can not open file.";
}
}
@masazdream
masazdream / harriscorners.cpp
Created February 15, 2014 10:06
Harris Corner取得用の関数 dist用画像のHarris Corner座標に円を描く
// Harris's corners
void HarrisCorners(Mat& src, Mat& dist, vector<Point2f>& corners) {
goodFeaturesToTrack(src, corners, 200, 0.01, 2, Mat(), 2, true);
vector<Point2f>::iterator it_corner = corners.begin();
for (; it_corner != corners.end(); ++it_corner) {
float px = it_corner->x;
float py = it_corner->y;
circle(dist, Point(px, py), 1, Scalar(0, 0, 255), -1);
circle(dist, Point(px, py), 8, Scalar(0, 0, 255));
}
@masazdream
masazdream / Houghsline.cpp
Created February 15, 2014 10:08
Houghsline取得用関数 dist用画像に検出した直線を描く
// Hough's lines
void HoughLines(Mat& src, Mat& hough_image, vector<Vec4i>& lines) {
HoughLinesP(src, lines, 1, CV_PI / 180, 50, 100, 5);
vector<Vec4i>::iterator it = lines.begin();
for (; it != lines.end(); ++it) {
Vec4i lin = *it;
line(hough_image, Point(lin[0], lin[1]), Point(lin[2], lin[3]),
Scalar(0, 0, 255), 2, 4);
}
@masazdream
masazdream / abs.cpp
Created February 15, 2014 10:55
差分画像 grayとgaussianの差分をMat absにいれる場合
// gaussianとgrayの差分画像
absdiff(gray, gaussian, abs);
@masazdream
masazdream / binary.cpp
Created February 15, 2014 10:58
2値画像の作成(OTSUの方法もある)
adaptiveThreshold(gray, bin, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C,CV_THRESH_BINARY, 7, 8);
threshold(abs, bin, 0, 255, cv::THRESH_BINARY | cv::THRESH_OTSU);
@masazdream
masazdream / ImageStream.cpp
Created February 16, 2014 05:01
opencvを使った画像の入出力
/*
* ImageStream.cpp
*
* Created on: 2013/05/14
* Author: root
*/
#include "SprixImageStream.h"
#include <iostream>
#include <sstream>
@masazdream
masazdream / ImageStream.hpp
Created February 16, 2014 05:02
opencvを使った画像の入出力 Header
#ifndef IMAGE_STREAM_H_
#define IMAGE_STREAM_H_
/*
* ImageStream.hpp
*
* Created on: Jun 1, 2013
* Author: root
*/
#include <cv.h>
@masazdream
masazdream / sbout.java
Last active August 29, 2015 13:56
さくっと使いたくなることある。
/**
* 指定したStringBuilderをファイルに書き出す
*
* @param filePath
* @param sb
*/
public static void outputFile(String filePath, StringBuilder sb) {
try {
FileWriter fw = new FileWriter(filePath, false);
PrintWriter pw = new PrintWriter(new BufferedWriter(fw));
@masazdream
masazdream / build.xml
Created March 13, 2014 11:38
opencvを使ったcppコードをant contribでbuildする
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. -->
<project basedir="." default="build" name="jni">
<property environment="env" />
<property name="ECLIPSE_HOME" value="../../eclipse" />
<property name="debuglevel" value="source,lines,vars" />