Skip to content

Instantly share code, notes, and snippets.

View pr3sidentspence's full-sized avatar

Pr3sidentSpence pr3sidentspence

View GitHub Profile
We couldn’t find that file to show.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pr3sidentspence
pr3sidentspence / tripleCardToReady.ps1
Last active December 15, 2018 01:51
A powershell script that 1) takes scans of multiple docutments (postcards) on a dark grey background 2) splits them into individual images 3) straightens them if needed 4) crops them with about 50px of the background remaining as a border 5) cleans up said background in the case of a certain set of cards 6) checks with Microsoft's Cognitive Serv…
param(
[string]$ext = "bmp",
[float]$triplethresh = 0.09,
[float]$singlethresh = 0.04,
[string]$colour = 'rgb(55,60,56)',
[Parameter(Mandatory = $true)][int]$tempNum,
[string]$stopAfter = "",
[float]$rotThresh = 2,
[int]$max = 3,
@pr3sidentspence
pr3sidentspence / msVisionAPIphotoRotate.ps1
Created December 14, 2018 21:19
Powershell script that runs photos (default jpg) in current folder through Microsoft's Cognitive Services Vision API and rotates the photo to match the orientation that MSCSVapi has the most confidence in its caption of.
param(
[string]$ext = "jpg"
)
# Powershell script that runs photos (default jpg) in current folder through
# Microsoft's Cognitive Services Vision API and rotates the photo
# to match the orientation that MSCSVapi has the most confidence in its caption of.
New-Item -ItemType directory -Path $PSScriptRoot/temp -Force
function callMsAPI {
@pr3sidentspence
pr3sidentspence / templateChopper.ps1
Created December 3, 2018 23:02
Uses cropper function from findDocsInScanAndSeparate.ps1 but feeds it static coordinates, for when we used the templated scanning.
function chopper {
Get-ChildItem $PSScriptRoot -Filter *.jpg |
Foreach-Object {
[System.Collections.ArrayList]$gapInfo = @()
$gapInfo += $_
$gapInfo += 96
$gapInfo += 96
$gapInfo += 106
$gapInfo += 2379
$gapInfo += 133
@pr3sidentspence
pr3sidentspence / renamer.ps1
Created December 3, 2018 19:57
Script simply renames files as named by postcardscansimple.exe to an almalgamated version of it's BermanID.
Param(
[Parameter(Mandatory=$true)][string]$binder = $null
)
write-host renner started
Get-ChildItem -Filter *.bmp |
Foreach-Object {
# $origName = $_.FullName -replace 'f', '-front'
if ($_.BaseName -match '^[0-9]*[f|b]$') {
if ($_.BaseName -match 'f') {
$side = 'front'
@pr3sidentspence
pr3sidentspence / findDocsInScanAndSeparate.ps1
Last active December 3, 2018 18:40
Same as findDocsInScanAndSeparate.ps1 but handles files named with the BermanID schema. Updated to only use BermanID naming when it detects that the sources started that way.
# A PowerShell script to use ImageMagick to find documents
# arranged vertically in scanned images
# and crop out each into separate images.
#
# Usage: ./findGapsBetweenScans.ps1 [-extension abc] [-threshold float ][-nosource] [-nodelete]
#
# Will analyze all images with extention abc (default is bmp)
# in current folder.
#
# if -nodeltee switch is used then script will skip deleting of temp files
@pr3sidentspence
pr3sidentspence / FindDocsInScanAndSeparate.ps1
Last active December 3, 2018 21:09
This powershell script uses ImageMagick to find gaps between documents arranged vertically in a scanned image and crops out those images into individual files. Changed to fix BermanID output (no dash after B[0-9][A-Z]).
# A PowerShell script to use ImageMagick to find documents
# arranged vertically in scanned images
# and crop out each into separate images.
#
# Usage: ./findGapsBetweenScans.ps1 [-extension abc] [-threshold float ][-nosource] [-nodelete]
#
# Will analyze all images with extention abc (default is bmp)
# in current folder.
#
# if -nodeltee switch is used then script will skip deleting of temp files
@pr3sidentspence
pr3sidentspence / chop.bat
Last active December 3, 2018 21:33
chop.bat uses ImageMagick to cut all .bmp files in the current folder into three .BMP files. Usage: chop.bat optional:([topCut1] [bottomCut1] [topCut2] [bottomCut2] [topCut2] [bottomCut2])
ECHO off
SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
REM chop.bat uses ImageMagick to cut all .bmp files in the current folder
REM into three .BMP files.
REM
REM Usage:
REM chop.bat optional:([topCut1] [bottomCut1] [topCut2] [bottomCut2] [topCut2] [bottomCut2])
REM
REM If no arguments are provided chop.bat will use the following:
SET topCut1=0