Skip to content

Instantly share code, notes, and snippets.

View acarabott's full-sized avatar

Arthur Carabott acarabott

View GitHub Profile
@acarabott
acarabott / opencv-cpp-create-alpha-image.cpp
Created January 17, 2017 17:50
Adding alpha channel to a 3 channel openCV Mat
void createAlphaImage(const cv::Mat& mat, cv::Mat_<cv::Vec4b>& dst)
{
std::vector<cv::Mat> matChannels;
cv::split(mat, matChannels);
// create alpha channel
cv::Mat alpha = matChannels.at(0) + matChannels.at(1) + matChannels.at(2);
matChannels.push_back(alpha);
cv::merge(matChannels, dst);
@acarabott
acarabott / gen-ssh-keys
Created December 27, 2016 14:47
generate ssh keys using ed25519 as per https://blog.g3rt.nl/upgrade-your-ssh-keys.html
ssh-keygen -o -a 100 -t ed25519
@acarabott
acarabott / opencv-trackbar-lambda.cpp
Last active December 19, 2020 17:25
using c++11 lambdas with opencv 3 trackbar callbacks
#include <functional>
using TrackbarAction = std::function<void(int)>;
cv::namedWindow("win");
cv::TrackbarCallback trackbarCallback = [] (int pos, void* userdata) {
(*(TrackbarAction*)userdata)(pos);
};
@acarabott
acarabott / opencv-mouse-callback-lambda.cpp
Last active January 17, 2017 18:06
opencv mouse callback with c++11 lambda and capture
/*
if you don't need to do any captures you can just do
cv::setMouseCallback("win", [] (int event, int x, int y, int flags, void*userdata) {
std::cout << "mouse action!" << std::endl;
});
but if you need to do any captures, then you'll need to do this crap.
If you know of a better way then fork away...
*/
@acarabott
acarabott / extract_stills.sh
Last active August 29, 2015 14:13
ffmpeg - extract stills
# -i input file
# -r frames per second to extract
# -ss start time HH:MM:SS
# -t duration to extract in seconds
# -s image format (see below)
# output file format where %d will be the image number
ffmpeg -i video.mp4 -r 25 -ss 00:01:22 -t 7 -s hd1080 output-%d.png
# Image formats
# -------------
@acarabott
acarabott / plugin.py
Created November 1, 2014 19:56
Sublime Text 3 API, check if view scroll position is at bottom
# useful for implementing output view auto scrolling, only when at the bottom
def view_is_at_bottom(view):
layout_h = view.layout_extent()[1]
view_h = view.viewport_extent()[1]
view_y = view.viewport_position()[1]
line_h = view.line_height()
view_taller_than_content = layout_h <= view_h
at_bottom_of_content = view_y + view_h >= layout_h - line_h
@acarabott
acarabott / .bash_profile
Created May 30, 2014 05:58
running GUI apps on a remote machine's own display, e.g. for an openFrameworks installation
DISPLAY=":0"
export DISPLAY
@acarabott
acarabott / ofApp.cpp
Created April 23, 2014 12:26
get value from ofxUIIntSlider guiEvent
void ofApp::setup(){
myValue = 5;
gui->addIntSlider("MY_INT_SLIDER", 0, 10, myValue);
}
void ofApp::guiEvent(ofxUIEventArgs &e)
{
if (e.getName() == "MY_INT_SLIDER")
{
// the trick is in the cast....
@acarabott
acarabott / buildAndRun.sh
Last active October 12, 2016 20:50
openFrameworks Sublime Text Build
#!/bin/bash
# This lives in your project directory, alongside src/, bin/, config.make, etc
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
make Debug && make RunDebug;
@acarabott
acarabott / username.conf
Created January 12, 2014 12:15
OS X apache conf to allow symbolic links in Sites folder /etc/apache2/users/username.conf
<Directory "/Users/username/Sites/">
# Options Indexes MultiViews
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>