Skip to content

Instantly share code, notes, and snippets.

View wngreene's full-sized avatar

W. Nicholas Greene wngreene

View GitHub Profile
@wngreene
wngreene / video_to_images.sh
Created April 2, 2020 22:49
Extract frames from a video.
#! /usr/bin/env bash
# Extract frames from a video.
INPUT_FILE=${1}
OUTPUT_DIR=${2}
FMT=${3-%010d.png}
# QUALITY=${4-1}
if [ ! -d ${OUTPUT_DIR} ]; then
@wngreene
wngreene / images_to_video.sh
Last active April 2, 2020 22:57
Convert folder of images to an h264 video.
#! /usr/bin/env bash
# Create a video from a folder of images.
FOLDER=${1}
OUTPUT_FILE=${2}
FPS=${3-30}
FMT=${4-%010d.png}
CODEC=${5-libx264rgb}
CRF=${6-0} # 0-lossless, 18-"visually" lossless, 23-default, 51-most compression.
@wngreene
wngreene / Dockerfile.devel-aarch64-cpu
Created September 13, 2019 16:30
Dockerfile for tensorflow_serving devel image on arm64 CPU. Build run image from this one.
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@wngreene
wngreene / publish_video.py
Created August 1, 2017 18:41
Publish a video as ROS messages.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2016 Massachusetts Institute of Technology
"""Publish a video as ROS messages.
"""
import argparse
@wngreene
wngreene / ogre_shaders.cpp
Created March 24, 2017 15:49
How to manually load shaders in Ogre. Copied from http://www.ogre3d.org/forums/viewtopic.php?f=2&t=73197
Ogre::HighLevelGpuProgramPtr vertex = Ogre::HighLevelGpuProgramManager::getSingletonPtr()->createProgram( "basicVS", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "glsl", Ogre::GpuProgramType::GPT_VERTEX_PROGRAM);
vertex->setSourceFile( "basic.vert" );
Ogre::HighLevelGpuProgramPtr fragment = Ogre::HighLevelGpuProgramManager::getSingletonPtr()->createProgram( "basicFS", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "glsl", Ogre::GpuProgramType::GPT_FRAGMENT_PROGRAM);
fragment->setSourceFile( "basic.frag" );
//Creating new material
Ogre::MaterialPtr matPtr = Ogre::MaterialManager::getSingletonPtr()->create( "ProgramShader", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
Ogre::Pass* pass = matPtr->getTechnique(0)->getPass(0);
@wngreene
wngreene / script.py
Created October 27, 2016 20:42
Python script boilerplate.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
pass
if __name__ == '__main__':
main()
@wngreene
wngreene / ansi_color.el
Created September 23, 2016 18:06
Snippet to fix colors in emacs compile buffer.
;; ansi-color.
;; https://emacs.stackexchange.com/questions/8135/why-does-compilation-buffer-show-control-characters
(use-package ansi-color
:ensure t
:config (progn
(defun my/ansi-colorize-buffer ()
(let ((buffer-read-only nil))
(ansi-color-apply-on-region (point-min) (point-max))))
(add-hook 'compilation-filter-hook 'my/ansi-colorize-buffer)))
@wngreene
wngreene / lcmlog_to_rosbag_image.py
Created September 8, 2016 20:15
Convert an LCM log to a ROS bag (mono/stereo images only).
#!/usr/bin/env python
import argparse
import yaml
import numpy as np
import lcm
from mav import image_t
import rosbag
@wngreene
wngreene / publish_video.py
Created July 3, 2016 22:42
Publish a video as ROS messages.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2016 Massachusetts Institute of Technology
"""Publish a video as ROS messages.
"""
import argparse
@wngreene
wngreene / bag_to_images.py
Last active May 2, 2024 05:14
Extract images from a rosbag.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2016 Massachusetts Institute of Technology
"""Extract images from a rosbag.
"""
import os
import argparse