Skip to content

Instantly share code, notes, and snippets.

View Harold2017's full-sized avatar
😃

Harold Harold2017

😃
View GitHub Profile
@Harold2017
Harold2017 / make_vtk_camera.cpp
Created March 1, 2024 02:47 — 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
// ------------------------------------------------------------------------
// Benchmark LGCG Time LTO Time Iterations LTCG Build LTO Build
// ------------------------------------------------------------------------
// regex_boost 317 ns 69.1 ns 2133333 00:02.720 00:08.70
// regex_ctre 248 ns 4.79 ns 2800000 05:08.755 00:04.78
// regex_hyperscan 96.7 ns n/a 7466667 00:52.487 n/a
// regex_re2 186 ns 3.97 ns 4072727 00:03.353 00:05.94
// regex_spirit 44.3 ns 0.644 ns 15448276 00:03.487 00:05.25
// regex_std 2371 ns 67.2 ns 280000 00:02.442 00:05.54
// regex_xpressive 552 ns 273 ns 1000000 00:05.369 00:11.52
@Harold2017
Harold2017 / ANSI-color-codes.h
Created May 14, 2022 12:15 — forked from RabaDabaDoba/ANSI-color-codes.h
The entire table of ANSI color codes working in C!
/*
* This is free and unencumbered software released into the public domain.
*
* For more information, please refer to <https://unlicense.org>
*/
//Regular text
#define BLK "\e[0;30m"
#define RED "\e[0;31m"
#define GRN "\e[0;32m"
@Harold2017
Harold2017 / ctz_clz.cpp
Created May 4, 2022 12:53 — forked from pps83/ctz_clz.cpp
__builtin_ctz (ctzl, ctzll) and __builtin_clz (clzl, clzll) for Visual Studio
#ifdef _MSC_VER
#include <intrin.h>
static inline int __builtin_ctz(unsigned x) {
unsigned long ret;
_BitScanForward(&ret, x);
return (int)ret;
}
static inline int __builtin_ctzll(unsigned long long x) {
@Harold2017
Harold2017 / compiletime-strings.hpp
Last active December 22, 2021 09:46 — forked from jgcoded/compiletime-strings.hpp
C++ Compile time conversion of a number to a string
/*!
This file contains code to convert unsigned integers to strings
at compile-time, and then modify those strings include more
information.
One use case is to convert library MAJOR, MINOR, and PATCH
numbers into a custom string (see below).
Other types like signed integers and floats can be added
with template specializition on the converter struct.
@Harold2017
Harold2017 / cameraToWorld.cs
Created November 19, 2021 02:37 — forked from tarukosu/cameraToWorld.cs
HoloLens カメラ座標から世界座標への変換
void OnPhotoCaptured(PhotoCapture.PhotoCaptureResult result, PhotoCaptureFrame photoCaptureFrame)
{
Matrix4x4 cameraToWorldMatrix;
photoCaptureFrame.TryGetCameraToWorldMatrix(out cameraToWorldMatrix);
Matrix4x4 projectionMatrix;
photoCaptureFrame.TryGetProjectionMatrix(out projectionMatrix);
var imagePosZeroToOne = new Vector2(pixelPos.x / imageWidth, 1 - (pixelPos.y / imageHeight));
var imagePosProjected = (imagePosZeroToOne * 2) - new Vector2(1, 1); // -1 to 1 space
@Harold2017
Harold2017 / git-commit-log-stats.md
Created July 13, 2021 05:40 — forked from eyecatchup/git-commit-log-stats.md
Some commands to get git commit log statistics for a repository on the command line.

git commit stats

Commands to get commit statistics for a Git repository from the command line -
using git log, git shortlog and friends.




@Harold2017
Harold2017 / circ_shift.h
Created April 12, 2021 02:10 — forked from tesch1/circ_shift.h
Eigen circShift and fftshift and ifftshift
// circ_shift.h
// https://stackoverflow.com/questions/46077242/eigen-modifyable-custom-expression/46301503#46301503
// this file implements circShift, fftshift, and ifftshift for Eigen vectors/matrices.
//
#pragma once
#include <Eigen/Core>
template <bool B> using bool_constant = std::integral_constant<bool, B>;
@Harold2017
Harold2017 / Eigen2CV.h
Created December 14, 2020 04:17 — forked from BloodAxe/Eigen2CV.h
This header file contains code snippet for easy mapping Eigen types to OpenCV and back with minimal overhead.
/**
* @brief Mapping functions from Eigen data types to OpenCV
* @author Eugene Khvedchenya <ekhvedchenya@gmail.com>
* @details This header file contains code snippet for easy mapping Eigen types to OpenCV and back with minimal overhead.
* @more computer-vision.talks.com/articles/mapping-eigen-to-opencv/
* Features:
* - Mapping plain data types with no overhead (read/write access)
* - Mapping expressions via evaluation (read only acess)
*
* Known issues:
@Harold2017
Harold2017 / qt-without-xcode.md
Created November 22, 2020 09:26 — forked from shoogle/qt-without-xcode.md
Qt without XCode - how to use Qt Creator for macOS software development without installing XCode

Qt without Xcode

How to use Qt Creator for software development on macOS without having to install Xcode

Justification

Qt refuses to install on macOS unless Apple's Xcode is installed beforehand. This is unfortunate because: