Skip to content

Instantly share code, notes, and snippets.

# This allows us to read the cities.json file. The format of the file
# is 'Javascript Object Notation' (JSON). It's a way of representing
# essential data structures, like lists and key-value pairs.
import json
# Our data will be in this format:
# {
# "city": "Beloit",
cmake -DPYTHON_DEFAULT_INTERPRETER=$(which python3) -DBUILD_opencv_python3=ON -DPYTHON3_LIBRARY=/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib -DPYTHON3_INCLUDE_DIR=/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/include/python3.9 ..
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bmount
bmount / halide_opencl_cache_kernel.cc.diff
Created June 7, 2019 00:52
minimal diff showing kernel re-use
diff --git a/src/runtime/opencl.cpp b/src/runtime/opencl.cpp
index 3fb98b4..4b5eca2 100644
--- a/src/runtime/opencl.cpp
+++ b/src/runtime/opencl.cpp
+} // extern C
+
+#include <map>
+struct kernel_cache_t { bool cached; cl_kernel kernel; inline kernel_cache_t() : cached(false) {} };
+std::map<const char*, kernel_cache_t> precompiled_kernels;
@bmount
bmount / gstreamer_udp_rtsp.md
Last active November 14, 2021 16:20
gstreamer udp rtsp

Snippets collected/distilled from gists/blog posts/etc. Combined here for fellow web-searchers -- goal is to have an easy/minimal sink for in-app use, and then forward that stream in another process.

Read camera, push to UDP sink (usually from appsrc, here v4l2 camera):

$ gst-launch-1.0 -vvvv v4l2src ! 'video/x-raw, width=640, height=480, framerate=30/1' ! videoconvert ! x264enc pass=qual quantizer=20 tune=zerolatency ! rtph264pay ! udpsink port=1234

Visualize above:

$ gst-launch-1.0 -vvv udpsrc port=1234 ! "application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" ! rtph264depay ! h264parse ! decodebin ! videoconvert ! xvimagesink sync=false

@bmount
bmount / sign_apk.txt
Created January 10, 2018 08:46
sign apk
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore some.apk alias_name
@bmount
bmount / tf-transform-graph.example
Created July 13, 2017 10:04
(Minimal) conversion of TensorFlow object detection graph for inference
bazel build tensorflow/tools/graph_transforms:transform_graph
bazel-bin/tensorflow/tools/graph_transforms/transform_graph --in_graph=../models/object_detection/ssd_mobilenet_v1_coco_11_06_2017/frozen_inference_graph.pb --out_graph=transformed_inference_graph.pb --inputs='image_tensor' --outputs='detection_boxes,detection_scores,detection_classes,num_detections' --transforms='
add_default_attributes
strip_unused_nodes(type=float)
remove_nodes(op=CheckNumerics)
fold_constants(ignore_errors=true)
fold_batch_norms
fold_old_batch_norms
fuse_resize_pad_and_conv
fuse_pad_and_conv
layer {
name: "Data1"
type: "Data"
top: "Data1"
top: "Data2"
transform_param {
mean_file: "/home/zl499/caffe/examples/cifar10/mean.binaryproto"
}
data_param {
source: "/home/zl499/caffe/examples/cifar10/cifar10_train_lmdb"
name: "PVANET-lite"
# https://raw.githubusercontent.com/sanghoon/pva-faster-rcnn/master/models/pvanet/lite/original.pt
################################################################################
## Input
################################################################################
layer {
name: 'input-data'
name: "SqueezeNet_Residual"
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {