Skip to content

Instantly share code, notes, and snippets.

View yuki-inaho's full-sized avatar

yuki-inaho

View GitHub Profile
import sys
import re
import os
import glob
import shutil
import copy
try :
import cv2
except :
@yuki-inaho
yuki-inaho / colorize_long_int_img.py
Last active January 14, 2020 02:27
Colorize Long Int 1Channel Images (such as IR, Depth...)
def colorize_long_int_img(img, max_var):
img_colorized = np.zeros([img.shape[0],img.shape[1],3]).astype(np.uint8)
img_colorized[:,:,1]=255
img_colorized[:,:,2]=255
img_hue = img.copy().astype(np.float32)
img_hue[np.where(img_hue > max_var)] = 0
zero_idx = np.where((img_hue>max_var) | (img_hue == 0))
img_hue *= 255.0/max_var
img_colorized[:,:,0] = img_hue.astype(np.uint8)
img_colorized = cv2.cvtColor(img_colorized, cv2.COLOR_HSV2RGB)
@yuki-inaho
yuki-inaho / PointCloud2_to_PCD.py
Created March 18, 2020 13:49
PointCloud2_to_PCD.py
import ros_numpy
import rospy
from sensor_msgs.msg import PointCloud2
import open3d as o3d
class PointCloud2Converter:
def __init__(self):
self.pc_npy = None
self.sub_pc = rospy.Subscriber('/aspara_detector/ground_point_cloud', PointCloud2, self.callback_pcl)
self.pcd = o3d.geometry.PointCloud()
@yuki-inaho
yuki-inaho / EmptyReaderDCAM710.cpp
Last active May 18, 2020 11:51
To check function call statistics without depth image processing
#include <vector>
#include <cmath>
#include <iostream>
#include "PicoZense_api.h"
using namespace std;
int main(int argc, char *argv[])
{
PsReturnStatus status;
int32_t deviceIndex = 0;
@yuki-inaho
yuki-inaho / Dockerfile
Last active June 23, 2020 07:03
Install vscode on docker (partitional)
# vscode
RUN wget -O vscode-amd64.deb https://go.microsoft.com/fwlink/?LinkID=760868
RUN apt-get update && apt-get install -y gdebi
RUN yes | gdebi vscode-amd64.deb
RUN rm vscode-amd64.deb
@yuki-inaho
yuki-inaho / convert_see3cam_toml_720p_to_1080p.py
Last active September 9, 2020 16:00
convert intrinsic parameters of see3cam so as to conform 720p to 1080p
import os
import toml
import click
from collections import OrderedDict
from ruamel import yaml # "import yaml" cannot deal with nested list
import pdb
import copy
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@yuki-inaho
yuki-inaho / ndarray_median_with_completion.py
Last active September 10, 2020 09:39
ndarray element-wise median with completion check
'''
$ python ndarray_median_with_completion.py
[[1 2 1]
[2 1 2]
[1 2 1]]
'''
from typing import List
import numpy as np
@yuki-inaho
yuki-inaho / see3cam_cu20_ae_setting_test.py
Created January 12, 2021 02:52
Auto Exposure setting test for See3CAM CU20
import os
from pyudev import Context
import errno
import sys
from select import select
from time import sleep
# Based on below code
# https://github.com/econsysqtcam/qtcam/blob/6b9d31bb7fa9ecf619987cc1433c1ac2398706fe/src/see3cam_cu20.cpp
@yuki-inaho
yuki-inaho / extract_complementary_images.py
Created March 15, 2021 02:44
extract_complementary_images.py
import shutil
import cv2
import numpy as np
from pathlib import Path
from tqdm import tqdm
import pdb
def get_image_pathes(input_dir_pathlib: Path):
extf = [".jpg", ".png"]
@yuki-inaho
yuki-inaho / generate_train_val_txt.py
Last active June 11, 2021 03:30
A script to generate train-validation splitted image-list files
import os
import shutil
import argparse
import numpy as np
from pathlib import Path
from scripts.utils import get_image_pathes
SCRIPT_DIR = str(Path(__file__).parent)
USERNAME = os.getenv("USER")