Skip to content

Instantly share code, notes, and snippets.

View benoitrosa's full-sized avatar

Benoit Rosa benoitrosa

View GitHub Profile
from sklearn.utils import shuffle
from sklearn.model_selection import KFold, StratifiedKFold
import numpy as np
n_1 = 50 # elements in data1
n_2 = 10 # elements in data2
n_folds = 3
alpha = 0.2
datasource1 = np.arange(0,n_1)
@benoitrosa
benoitrosa / CMakeLists.txt
Created November 17, 2017 09:31
CMakeLists MTF using config
cmake_minimum_required(VERSION 2.8)
include(mtfConfig.cmake)
include_directories(${MTF_INCLUDE_DIRS})
add_definitions(${MTF_CXX_FLAGS})
add_executable(test_MTF test_MTF.cpp)
@benoitrosa
benoitrosa / mtfConfig.cmake.in
Created November 17, 2017 09:26
Input file for MTF config file generator
# - Basig config file generator for the MTF package
# It defines the following variables
# MTF_INCLUDE_DIRS - include directories for MTF
# MTF_CXX_FLAGS - Compile flags for GCC
# MTF_LIBRARIES - libraries to link against
# MTF_DEFS - Preprocessor definitions for MTF
# MTF_VERSION - The current MTF version
# MTF_LIB_DIRS - Dir where MTF compiled lib is installed
# Compute paths
@benoitrosa
benoitrosa / CMakeLists.txt
Last active November 16, 2017 13:23
MTF CMakeLists
cmake_minimum_required(VERSION 2.8)
find_package (Eigen3 REQUIRED DENSE)
include_directories(${EIGEN3_INCLUDE_DIR})
find_package( OpenCV REQUIRED )
include_directories(${OpenCV_INCLUDE_DIRS})
set(MTF_LIBS mtf boost_system)
set(MTF_INCLUDE_DIRS /usr/local/include/mtf)
@benoitrosa
benoitrosa / VTK_camera_intrinsics.py
Created October 3, 2017 16:38
Example for setting camera intrinsics in VTK using python
import vtk
import numpy as np
from vtk.util import numpy_support
import cv2
class Camera_VTK():
"""
Example class showing how to project a 3D world coordinate onto a 2D image plane using VTK
@benoitrosa
benoitrosa / test_norm.py
Created August 29, 2017 07:33
Numpy linalg.norm(A) vs np.sqrt(np.inner(A,A)
import numpy as np
import timeit
def norm(A):
if A.ndim == 1:
return np.sqrt(np.inner(A,A))
return np.linalg.norm(A)
def time_norms(A, n_eval):
start_time = timeit.default_timer()
@benoitrosa
benoitrosa / make_vtk_camera.cpp
Created March 1, 2017 16:17 — forked from decrispell/make_vtk_camera.cpp
Convert standard camera intrinsic (focal length, principal point) and extrinsic parameters (rotation and translation) into a vtkCamera for rendering. Assume square pixels and 0 skew for now.
/**
* Convert standard camera intrinsic and extrinsic parameters to a vtkCamera instance for rendering
* Assume square pixels and 0 skew (for now).
*
* focal_len : camera focal length (units pixels)
* nx,ny : image dimensions in pixels
* principal_pt: camera principal point,
* i.e. the intersection of the principal ray with the image plane (units pixels)
* camera_rot, camera_trans : rotation, translation matrix mapping world points to camera coordinates
* depth_min, depth_max : needed to set the clipping range