Skip to content

Instantly share code, notes, and snippets.

View kazuki-ma's full-sized avatar
😀
Please feel free to contact.

Kazuki MATSUDA / 松田一樹 kazuki-ma

😀
Please feel free to contact.
View GitHub Profile
@kazuki-ma
kazuki-ma / gist:1888265
Created February 22, 2012 23:13
パディングを回避する
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
// カスタムアロケータ
namespace cvut
{
template<int alignment_bytes>
class customAllocator: public cv::MatAllocator
{
@kazuki-ma
kazuki-ma / allocator.hpp
Created February 24, 2012 14:13
OpenCV Custom Allocator for OpenGL, DirectX, QImage
// Custom Allocator for OpenCV's cv::Mat
// this code samples writen by facebook.com/matsuda.kazuki and published under public domain.
// You can copy and use this code in any situation under any license.
#ifndef __CVUT_ALLOCATOR__
#define __CVUT_ALLOCATOR__ 1
#include <opencv2/core/core.hpp>
public class test{
public static void main(String args[]){
Runnable lammda = new Runnable() {
@Override
public void run() {
System.out.println("Run!");
}
};
lammda.run();
@kazuki-ma
kazuki-ma / TestSynchronized.java
Created May 16, 2012 11:27
Long をロックする注意
public class TestSynchronized {
public static void main(String[] args) {
Runnable action = new Runnable() {
Long var = new Long(0); // Long 方 var
public void run() {
for (long i = 0; i < 10_000_000L; ++i) { // 1000万回ループ内で
synchronized (var) { // ロックして
var++; // インクリメント!
}
}
@kazuki-ma
kazuki-ma / auto_library_linking.patch
Created June 25, 2012 11:00
OpenCV auto library linking for Visual Studio / OpenCV 2.4.1
Index: modules/calib3d/include/opencv2/calib3d/calib3d.hpp
===================================================================
--- modules/calib3d/include/opencv2/calib3d/calib3d.hpp (revision 8696)
+++ modules/calib3d/include/opencv2/calib3d/calib3d.hpp (working copy)
@@ -748,4 +748,10 @@
#endif
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
@kazuki-ma
kazuki-ma / random.cpp
Created September 18, 2012 13:47
tetlist::random
#include <stdint.h>
#include <random>
namespace tetlist{
template <typename IntType>
class random{
#if defined(_WIN64) || defined(__LP64__)
typedef std::mt19937_64 mt19937;
#else
typedef std::mt19937 mt19937;
@kazuki-ma
kazuki-ma / ransac.h
Created September 18, 2012 13:49
Ransac -- RANdom SAmple Consensus
#include "stdafx.h"
namespace tetlist{
template <typename DATATYPE, typename FIT_PARAM, typename ACCURANCY = float>
class ransac{
public:
typedef std::vector<DATATYPE> DATAM;
typedef FIT_PARAM FIT_PARAM;
typedef void (fitting)(
@kazuki-ma
kazuki-ma / opencv_speec_test.cpp
Created October 21, 2012 10:10
opencv_speec_test.cpp
#include <cstddef>
#include <cstdint>
#include <time.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#pragma comment(lib, "opencv_core249.lib")
#pragma comment(lib, "opencv_highgui249.lib")
@kazuki-ma
kazuki-ma / chain_loop.pl
Created October 29, 2012 12:06
chain_loop
# チェーン無限ループ
sub foo :Chained('/foo') :CaptureArg(1){
}
@kazuki-ma
kazuki-ma / cv_mat_foreach.cpp
Last active April 29, 2022 06:01
test code for cv::Mat::forEach
#include <opencv2/core.hpp>
typedef cv::Point3_<uint8_t> Pixel;
typedef cv::Mat_<Pixel> MatT;
const cv::Size SIZE_FULL_HD(1920, 1020);
void ShowResult(const std::string name, const double time) {
std::cout << cv::format("%40s | %20.10f", name.c_str(), time) << std::endl;
return;
}