domingo, 5 de outubro de 2014

Transform matrix in a vector - Python using numpy

1 a = np.arange(10).reshape(2,5)
2 print a
3 a = a .ravel
4 print a
_____________________________________________________
2: array([[0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9]])
4: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

quarta-feira, 1 de outubro de 2014

numpy ndarray to cvmat


1 import cv
2 print type(image)
3 new_image = cv.fromarray(image)
4 print type(new_image)
______________________________________________________:
2: cv2.cv.cvmat
4: type 'numpy.ndarray 

Ternary operator python - Operador ternário python

>>> a = (False,True)[True]
>>> a
 True
>>> a = (False,True)[False]
>>> a
False
>>> a= (False, True) [3%2 == 0]
False

Using Shapely - intersection between bouding boxes

Discovering the area of intersection between two bounding boxes using Shapely

1 from shapely.geometry import box
2 b = box(5.0, 5.0, 10.0, 10.0)
3 c = box(0.0, 0.0, 5.0, 5.0)
4 print (b.intersection(c)).area
_________________________________
4: 0.0