#displaying image
cv2.namedWindow("img",cv2.WINDOW_AUTOSIZE)  
cv2.imshow("img",img)
cv2.waitKey(0)

#creating grid and finding objects
dirg = gr.grid(img,32)

for i in range(1):
   blobs = dirg.locate(img)

   for blob in blobs:
      print "pt, area: ",blob.pt,blob.area()
   
   blobs = bl.ordered(blobs)
   
   print " "
   for blob in blobs:
      print "pt, area: ",blob.pt,blob.area()

   for blob in blobs:
      blob.mark(img)

   #displaying image
   cv2.imshow("img",img)
   cv2.waitKey(0)

   dirg.add(blobs)

dirg.det(img)
		if frame is None:
			break

		#equalizing histogram TODO: find another function
		#hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
		#h, s, v = cv2.split(hsv)
		#v = cv2.equalizeHist(v)
		#hsv = cv2.merge([h,s,v])
		#frame2 = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)

		#converting to HSV and thresholding
		frame2 = cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
		frame2 = cv2.inRange(frame2,lower,upper)

		#finding ordered blobs
		blobs = bl.ordered(dirg.locate(frame2))
		#marking them in image
		for blob in blobs:
			blob.mark(frame2)
		#adding points to container
		dirg.add(blobs)

	#checking integrity of image
	if frame is None:
		break
	
	#finding x coordinate of definitive object	
	x = dirg.det()
	#marking a line on it
	frame2[:,x] = 255
	#refreshing container