Skip to content

Instantly share code, notes, and snippets.

extension Array where Element == OCRCandidate {
func sortCandidates() -> [OCRCandidate] {
self.sorted { (currentCandidate, nextCandidate) -> Bool in
let currentCandidateBottomY = currentCandidate.boundingPoints.avgBottomY
let nextCandidateBottomY = nextCandidate.boundingPoints.avgBottomY
if currentCandidateBottomY < nextCandidateBottomY {
// Rounding item for discrepancies with Y positions.
let difference = (currentCandidateBottomY - nextCandidateBottomY).roundTo2dp
private func ocrRequestHandler(request: VNRequest, error: Error?) {
guard let observations = request.results as? [VNRecognizedTextObservation] else { return }
var ocrCandidates: [OCRCandidate] = []
for observation in observations {
guard let topCandidate = observation.topCandidates(1).first else { return }
// Vision algorithms use a coordinate system with lower left origin.
// Converting to upper left so the y values are increasing as the bounding box for observation
// goes down the list as to how humans read english text.

Ubuntu 22.04 for Deep Learning

In the name of God

This gist contains steps to setup Ubuntu 22.04 for deep learning.


Install Ubuntu 22.04

@JasonAtNvidia
JasonAtNvidia / txdocker
Last active March 8, 2022 08:15
Short Bash script to enable use of the GPU within a docker container running on an NVIDIA Jetson TX2. Place inside /usr/local/bin/, chmod +x txdocker, ensure it is in your system PATH, and use just as you would the docker command.
#!/bin/bash
#Jason T. 2-6-2018
# Check specifically for the run command
if [[ $# -ge 2 && $1 == "run" ]]; then
# Tell docker to share the following folders with the base system
# This allows the docker containers to find CUDA, cuDNN, TensorRT
LIB_MAPS="/usr/lib/aarch64-linux-gnu \
/usr/local/cuda \
/usr/local/cuda/lib64"
@CodeMyUI
CodeMyUI / index.html
Created February 21, 2018 03:24
YGC V2 Timeline
<section id="cd-timeline" class="cd-container">
<div class="cd-timeline-block">
<div class="cd-timeline-img cd-picture">
</div>
<div class="cd-timeline-content">
<h2>Penta Consulting</h2>
<div class="timeline-content-info">
<span class="timeline-content-info-title">
<i class="fa fa-certificate" aria-hidden="true"></i>
@mbinna
mbinna / effective_modern_cmake.md
Last active March 19, 2026 06:40
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@natsupy
natsupy / TextureTools.cs
Last active November 8, 2023 03:59
Crop and resize texture in unity editor! Open it: Press F1
using System.Collections.Generic;
using System.IO;
using System.Collections;
using UnityEditor;
using UnityEngine;
using System;
using System.Threading;
public class Utilities : EditorWindow
{
@meetps
meetps / computeIoU.py
Created February 11, 2017 14:02
Intersection over Union for Python [ Keras ]
import numpy as np
def computeIoU(y_pred_batch, y_true_batch):
return np.mean(np.asarray([pixelAccuracy(y_pred_batch[i], y_true_batch[i]) for i in range(len(y_true_batch))]))
def pixelAccuracy(y_pred, y_true):
y_pred = np.argmax(np.reshape(y_pred,[N_CLASSES_PASCAL,img_rows,img_cols]),axis=0)
y_true = np.argmax(np.reshape(y_true,[N_CLASSES_PASCAL,img_rows,img_cols]),axis=0)
y_pred = y_pred * (y_true>0)
@wngreene
wngreene / bag_to_images.py
Last active January 14, 2025 05:58
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
@zancas
zancas / pypi-vs-npm.md
Last active September 19, 2021 08:25 — forked from toejough/pypi-vs-npm.md

Intro

This is a comparison of packaging with python vs with npm.

TLDR

Python packaging is 3x as complex as javascript packaging. See the conclusion for more detail (but less than the whole document).

Categories examined:

  • [script creation](script creation)
  • [conversion to a package](conversion to a package)