Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import cv2
import time,sys,os
ply_header = '''ply
format ascii 1.0
element vertex %(vert_num)d
property float x
property float y
property float z
@abidrahmank
abidrahmank / sfm.py
Created September 5, 2013 13:21
SfM.py
import numpy as np
import cv2
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import axes3d
FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks = 50)
flann = cv2.FlannBasedMatcher(index_params, search_params)
@abidrahmank
abidrahmank / gist:6146351
Created August 3, 2013 12:54
epiline.py
import cv2
import numpy as np
from matplotlib import pyplot as plt
def drawlines(img1,img2,lines,pts1,pts2):
''' img1 - image on which we draw the epilines for the points in img1
lines - corresponding epilines '''
r,c = img1.shape
import cv2
import numpy as np
from matplotlib import pyplot as plt
def drawlines(img1,img2,lines,pts1,pts2):
''' img1 - image on which we draw the epilines for the points in img1
lines - corresponding epilines '''
r,c = img1.shape
@abidrahmank
abidrahmank / gist:5652354
Last active December 17, 2015 18:19
profile multiprocess code
In [8]: %prun single_process(contours)
6000013 function calls in 39.007 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
3000000 36.424 0.000 36.424 0.000 {cv2.pointPolygonTest}
1 2.056 2.056 39.006 39.006 pointpolygontest.py:18(single_process)
3000000 0.514 0.000 0.514 0.000 {method 'itemset' of 'numpy.ndarray' objects}
4 0.010 0.002 0.010 0.002 {numpy.core.multiarray.zeros}
@abidrahmank
abidrahmank / pt.py
Created May 26, 2013 09:53
multiprocessing
import cv2,time
import numpy as np
from multiprocessing.pool import ThreadPool
img = cv2.imread('img2.png',0)
ret,src = cv2.threshold(img,127,255,0)
contours,hierarchy = cv2.findContours(src,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
@abidrahmank
abidrahmank / gist:5281486
Created March 31, 2013 18:08
MMX v/s SSE2 Performance Comparison
.model C,flat
.data
.code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; MMX ASSEMBLY
;
@abidrahmank
abidrahmank / gist:4540887
Created January 15, 2013 18:40
Result data
>>> centroids
[[98, 325], [232, 309], [472, 294], [96, 192], [453, 167], [84, 66], [445, 46]]
>>> match_pts
[[84, 310], [208, 310], [456, 310], [84, 188], [456, 188], [84, 66], [456, 66]]
>>> centroids
[[329, 894], [463, 878], [703, 863], [327, 761], [684, 736], [315, 635], [676, 615]]
>>> sorted(centroids,key = lambda s:sum)
[[329, 894], [463, 878], [703, 863], [327, 761], [684, 736], [315, 635], [676, 615]]
>>>
#include <iostream>
using namespace std;
struct MyStruct
{
int x;
};
void updateStruct (MyStruct my_struct)
{