Skip to content

Instantly share code, notes, and snippets.

@gylns
gylns / subs.cpp
Last active November 23, 2016 00:29
/* from vlfeat/mser.c
print:
-1 -1 -1
0 -1 -1
1 -1 -1
.......
-1 1 1
0 1 1
1 1 1
*/
/*
histogram sort, from vlfeat/mser.c
*/
/* -----------------------------------------------------------------
* Sort pixels by intensity
* -------------------------------------------------------------- */
{
vl_uint buckets [ VL_MSER_PIX_MAXVAL ] ;
VideoCapture cap(path + "/%d.jpg");
while(cap.isOpened())
{
Mat image;
cap >> image;
if(image.empty())
break;
/* image processing */
}
f=(*.jpg)
i=({01..37})
for ((j=0; j<=${#f[@]}; j++))
do
mv ${f[j]} ${i[j]}.jpg
done
javascript:(function () {
var rl = document.getElementById("results-list");
var tl = rl.getElementsByClassName("text");
for (var t of tl)
{
var title = t.getElementsByClassName("title")[0];
var subtitle = t.getElementsByClassName("subtitle")[0];
var year = t.getElementsByClassName("year")[0];
title.innerHTML += " " + subtitle.innerHTML + (subtitle.innerHTML ? " " : "") + year.innerHTML;
title.href = title.href.replace(/\/book\//,"/content/pdf/") + ".pdf";
var lt = document.getElementsByClassName("floatLeft");
for (var it of lt)
{
var link = it.lastElementChild.href;
var bkn = /bkn=([^&]*)&/.exec(link)[1];
var fn = /=([^.]*)\.pdf/.exec(link)[1];
it.lastElementChild.href= "/ebooks/"+bkn+"/"+fn+".pdf?bkn="+bkn+"&pdfType=chapter";
}
#include <queue>
#include <iostream>
#include <opencv2/opencv.hpp>
#include "dirent.h"
using namespace std;
using namespace cv;
int main(int, char** argv)
{
# by pyimagesearch
# import the necessary packages
import numpy as np
import cv2
def order_points(pts):
# initialzie a list of coordinates that will be ordered
# such that the first entry in the list is the top-left,
# the second entry is the top-right, the third is the
# bottom-right, and the fourth is the bottom-left
//sorting points by clockwise using cross product
//see <http://stackoverflow.com/questions/6989100/sort-points-in-clockwise-order>
bool less(point a, point b)
{
if (a.x - center.x >= 0 && b.x - center.x < 0)
return true;
if (a.x - center.x < 0 && b.x - center.x >= 0)
return false;
if (a.x - center.x == 0 && b.x - center.x == 0) {
if (a.y - center.y >= 0 || b.y - center.y >= 0)
{
"type": "resolver",
"ns": "nonymous",
"author": "gyl",
"prefix": "batch downloader for International Press",
"match": "^http://intlpress\\.com/.*/body\\.html",
"static": true,
"finder": "href=\"(.+pdf)\"",
"builder": "{1}"
}