Skip to content

Instantly share code, notes, and snippets.

View Lait-au-Cafe's full-sized avatar
📄
Hard to die, Harder to live.

lait-au-cafe Lait-au-Cafe

📄
Hard to die, Harder to live.
View GitHub Profile
package main
// #cgo pkg-config: opencv
// #include <opencv/cv.h>
// #include <opencv/highgui.h>
import "C"
import "unsafe"
func main(){
@Lait-au-Cafe
Lait-au-Cafe / grayscale.cu
Created October 12, 2017 03:11
CUDA + OpenCVでWebカメラから取得した画像を変換
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <helper_cuda.h>
#include <iostream>
#include <opencv2\opencv.hpp>
__global__ void grayscale(
uchar3* input,
uchar3* result,
//=============================================================================
// Includes
//=============================================================================
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <helper_functions.h>
#include <helper_cuda.h>
#include <iostream>
#define _USE_MATH_DEFINES
@Lait-au-Cafe
Lait-au-Cafe / memo.md
Last active August 27, 2020 18:53
GolangでWindows用にクロスコンパイルするときのメモ
$ sudo apt install gcc-multilib
$ sudo apt install gcc-mingw-w64

$ GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc go build -o hoge.exe hoge.go

$ GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -o hoge.exe hoge.go

amd64のほうは未検証

@Lait-au-Cafe
Lait-au-Cafe / bitonicsort.py
Created December 26, 2017 12:05
Bitonic Sort
import pyopencl as cl
import numpy as np
ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)
length = np.int32(256)
labelElements = np.zeros(length * 2, dtype=np.int32)
length_Buf = cl.Buffer(ctx, cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR, length.nbytes, hostbuf=length)
@Lait-au-Cafe
Lait-au-Cafe / Background.cs
Created December 30, 2017 13:29
AR Background
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Background : MonoBehaviour {
public WebCamTexture wtex;
// Use this for initialization
void Start () {
@Lait-au-Cafe
Lait-au-Cafe / Otsu.compute
Last active December 30, 2017 16:12
大津の手法を用いた二値化
// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel CSMain
// Create a RenderTexture with enableRandomWrite flag and set it
// with cs.SetTexture
StructuredBuffer<int> histogram;
RWStructuredBuffer<float2> result; //x:thresh, y:variable
float num1, num2; //画素数
@Lait-au-Cafe
Lait-au-Cafe / Otsu.compute
Created December 30, 2017 16:15
大津の手法を用いた二値化
#pragma kernel CreateHistogram
#pragma kernel MergeHistogram
#pragma kernel OtsuMethod
#pragma kernel Threshold
Texture2D<float4> Input;
float thresh;
RWTexture2D<float4> Result;
RWStructuredBuffer<uint> histogram : register(u0);
RWStructuredBuffer<uint> hbuffer;
@Lait-au-Cafe
Lait-au-Cafe / kernel.cl
Last active August 23, 2022 16:38
An example of OpenCV-CL (deal with grayscale textures)
__kernel void negaposi(
__global uchar* input,
int input_step, int input_offset,
__global uchar* result,
int result_step, int result_offset,
int height, int width
) {
int x = get_global_id(0);
int y = get_global_id(1);
@Lait-au-Cafe
Lait-au-Cafe / kernel.cl
Created March 7, 2018 17:11
An example of OpenCV-CL (deal with RGB textures)
__kernel void grayscale(
__global uchar* input,
int input_step, int input_offset,
__global uchar* result,
int result_step, int result_offset,
int height, int width
) {
int x = get_global_id(0);
int y = get_global_id(1);