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
@Lait-au-Cafe
Lait-au-Cafe / cpp_working_example.cpp
Created May 4, 2023 07:33
GetAllocatedString crashes with STATUS_ACCESS_VIOLATION.
#include <iostream>
#include <string>
#include <mfapi.h>
#include <mfidl.h>
void listup_webcams() {
IMFAttributes *p_attr = NULL;
HRESULT hr = MFCreateAttributes(&p_attr, 1);
if(FAILED(hr)){
std::cout
@import url(https://fonts.googleapis.com/css?family=Roboto:700);
@import url('https://fonts.googleapis.com/css2?family=Zen+Kaku+Gothic+New:wght@500&display=swap');
* {
box-sizing: border-box;
}
html, body {
height: 100%;
overflow: hidden;
@Lait-au-Cafe
Lait-au-Cafe / CSS
Last active June 19, 2022 14:25
みれなさん向けChatboxCSS
@import url(https://fonts.googleapis.com/css?family=Roboto:700);
* {
box-sizing: border-box;
}
html, body {
height: 100%;
overflow: hidden;
}
@Lait-au-Cafe
Lait-au-Cafe / GlobalInput.cs
Last active November 8, 2019 13:36
Handle key event when the app is running in background.
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
#region WIN32 TYPES
using DWORD = System.UInt64;
using HINSTANCE = System.IntPtr;
using HHOOK = System.IntPtr;
using WPARAM = System.IntPtr;
using LPARAM = System.IntPtr;
@Lait-au-Cafe
Lait-au-Cafe / main.rs
Created August 14, 2019 14:10
Product of digits.
use std::time::Instant;
fn split(mut n: u128) -> Vec<u8> {
let mut elems: Vec<u8> = Vec::new();
while n != 0 {
let e = n % 10;
elems.push(e as u8);
n /= 10;
}
@Lait-au-Cafe
Lait-au-Cafe / solve.cpp
Created April 15, 2019 02:33
Solve linear equation by OpenCV.
#include <iostream>
#include <opencv2/opencv.hpp>
int main() {
// solve the equations below.
// x+y+z=6
// x-y-z=-4
// x+y+2z=9
cv::Mat1f coef_mat(3, 4);
cv::Mat1f answer(3, 1);
@Lait-au-Cafe
Lait-au-Cafe / main.rs
Last active December 2, 2018 06:52
Rust Image crate example
extern crate image;
use std::env;
fn main() {
let mut args = env::args();
args.next(); // skip command name
let img_path = match args.next() {
None => {
@Lait-au-Cafe
Lait-au-Cafe / otsu_method.hlsl
Created July 21, 2018 06:20
大津の手法の並列実装
Texture2D<float4> Input;
RWTexture2D<float4> Result;
groupshared uint sbuffer[256]; //
groupshared float4 dbuffer[256]; //
groupshared float2 obuffer[256]; //
uint width; // テクスチャの幅
uint height;// テクスチャの高さ
[numthreads(32,32,1)]
@Lait-au-Cafe
Lait-au-Cafe / getThresh.cs
Created June 25, 2018 09:57
Binarization with Otsu Method
public int getThresh()
{
int th = 0; //ループ用の閾値
double num1, num2; //画素数
double sum1, sum2; //和
double m1, m2; //平均
double va_b; //クラス間分散の二乗
double max = 0; //va_bの最大値を保存しておく変数
//ヒストグラムを生成していなければ弾く
@Lait-au-Cafe
Lait-au-Cafe / calibration.cpp
Created April 3, 2018 12:28
OpenCVでカメラキャリブレーション(C++)
#include <iostream>
#include <cmath>
#include <vector>
#include <fstream>
#include <sstream>
#include <time.h>
#include <iomanip>
#include <opencv2/opencv.hpp>
#define PAT_ROW 7 // number of rows