Ask Your Question

AlanJ's profile - activity

2019-03-29 07:03:04 -0600 received badge  Enthusiast
2016-03-09 06:30:31 -0600 commented answer Identify trees in photo

CV2 only seems to have one sub module called cv and it is not in there. I am not sure what version of openCV I am using I thought i down loaded 3.0 but the version is reported as being 4557. I understand that that is a known bug. I am also having problems like cv2 variables not being available and commands returning different results from the documentation. It seems that there has been some upheaval in OpenCV, probably going to ver 3 and the document ation has not kept up and possibly some functions are not yet available. The result is that I am going to start using SciPi.

2016-03-08 10:04:28 -0600 commented answer Identify trees in photo

I cannot find a python version of the filter you suggest. I have got the findContours to work but the results are disappointing and I need to get a better filtered result before using that stage.

2016-03-04 06:53:13 -0600 commented answer Identify trees in photo

I will get back to you in a couple of days when I have followed up your suggestions

2016-03-04 05:49:33 -0600 commented question Identify trees in photo

I did use markers for another project - purple colored ones where best, but they had to be huge to be more than a couple of pixels wide at say 40m. I am not giving up on the trees yet.

2016-03-03 13:32:32 -0600 commented question Identify trees in photo

I have tried removing the green but it makes it worse. Funnily removing the blue gives something perhaps slightly better than grayscale but not much. Here is a link to the lines drawn. https://dl.dropboxusercontent.com/u/3... You can see that the lines do not seem to follow the outline of the trees

2016-03-03 07:43:33 -0600 asked a question Identify trees in photo

I am trying to use a camera to help localize my robot in my garden. I want to be able to identify trees as they are the most prominent features.

I am having great difficulty extracting the trees from the background. they seem to have the same colur as the surroundings so I cannot use that so i have been trying to identify the edges.

I have looked at each of RGB and HSV and none seperatly seem to show the edges better than grayscale.

I have used a bilateral filter as it is supposed to blur but maintain the edges and I have used a sobel filter to highlight the edges as it seems to make a better job on this than Cany.

Here is a link to the original test photo. link text

I only take the middle third of the picture to reduce the size and because that part has the treetrunks.

Here is my code:


import cv2
import numpy as np

thresh   = 0
sobel_8u = 0
gray     = 0
img      = 0
kernel   = 0

def changeThreshhold(x):

   global thresh,sobel_8u,gray,img
   ret,thresh = cv2.threshold(sobel_8u,x,255,cv2.THRESH_BINARY )

   img = np.vstack((gray,sobel_8u,thresh))

treeName = 'C:\Users\Alan\Desktop\Trees\tree4.jpg' imgC = cv2.imread(treeName,cv2.CV_LOAD_IMAGE_COLOR) h,w,c = np.shape(imgC) partImgC = imgC[h/2:2*h/3,:,:]

gry = cv2.cvtColor(partImgC,cv2.COLOR_BGR2GRAY) gray = cv2.equalizeHist(gry)

blur = cv2.bilateralFilter(gray,21,75,75) sobelx64f = cv2.Sobel(blur,cv2.CV_64F,1,0,ksize=3) abs_sobel64f = np.absolute(sobelx64f) sobel_8u = np.uint8(abs_sobel64f)

changeThreshhold(65)

cv2.namedWindow('image',cv2.cv.CV_WINDOW_NORMAL) cv2.createTrackbar('threshhold','image',65,255,changeThreshhold)

while(1): cv2.imshow('image',img) k = cv2.waitKey(1) & 0xFF if k == 27: break

cv2.destroyAllWindows() <\code><\pre>

The results are here:link text

They do not look so bad but when I try to use HoughLines to extract the lines and hence the trees I get a huge amount of rubbish.

Can anybody show me a better way.

Thanks Alan