Identifying the location of squares:
Since the cvHough2lines gives the horizontal lines without a problem, I started to find out what goes wrong with the vertical lines. In the process I hit a road block as I could not decipher how the (recursive) data structure cvSeq works - apparently if you have a pointer to cvSeq, say 'x', you can access the ith element of x using 'cvGetSeqElem'. Okay, so far it is clear. Then what they do is they cast that return value to a cvPoint, say 'point', and they would do something like point[0] and point[1] to get the starting and ending points to draw a line. Assuming that here 'point' gets those values from the hough transformation, I am fine with that step too.
I am actually baffled by why cvSeq would not give the vertical lines in this case. According to my understanding everything looks fine and it should display the verticals as well.
So to understand the real problem I thought of looking in to the code of the hough transformation implementation in open cv. If any one of you can hint what might be wrong here, please do comment. It could save a lot of my time.
Compensating for rotations in the image:
I thought of an algorithm to do this.
Here it goes...
BTW, I see a possible problem with this approach. Part of the image could be cropped.
If you can see better approaches to this problem, please do suggest.
That's about it for the moment..
In the mean time to refresh my memory on what Rajith taught us, I am going through a very nice tutorial as well :). Hope you would also find it useful.
Since the cvHough2lines gives the horizontal lines without a problem, I started to find out what goes wrong with the vertical lines. In the process I hit a road block as I could not decipher how the (recursive) data structure cvSeq works - apparently if you have a pointer to cvSeq, say 'x', you can access the ith element of x using 'cvGetSeqElem'. Okay, so far it is clear. Then what they do is they cast that return value to a cvPoint, say 'point', and they would do something like point[0] and point[1] to get the starting and ending points to draw a line. Assuming that here 'point' gets those values from the hough transformation, I am fine with that step too.
I am actually baffled by why cvSeq would not give the vertical lines in this case. According to my understanding everything looks fine and it should display the verticals as well.
So to understand the real problem I thought of looking in to the code of the hough transformation implementation in open cv. If any one of you can hint what might be wrong here, please do comment. It could save a lot of my time.
Compensating for rotations in the image:
I thought of an algorithm to do this.
Here it goes...
- Identify all the lines - they could be either horizontal or vertical in the actual aligned image.
- Take a particular line (could be horizontal or vertical)
- Calculate the angle theta between that line and the horizontal edge of the image
- Rotate the image by that theta amount: Some basic mathematics goes here!
BTW, I see a possible problem with this approach. Part of the image could be cropped.
If you can see better approaches to this problem, please do suggest.
That's about it for the moment..
In the mean time to refresh my memory on what Rajith taught us, I am going through a very nice tutorial as well :). Hope you would also find it useful.
2 comments:
Oshi,
As the Hough transform is going on and on with no ending, it's better to try another way. Did you try finding code examples in the web? Some of the samples helped me in understanding a lot.
For rotation compensating, I think you should find out how others have done that. As I remembers, Wiki had something about number plate recognition and rotation compensating. So before implementing ur algo, just look around.
We'll discuss issues once we meet!
P.S. Where are the other two???
About the hough transform:
I managed to find out where I was going wrong - I have been passing a wrong parameter along with the wrong number of parameters the whole time! What a waste of time...
However now we are able to identify all the lines! Yay!
About rotation compensation:
Didn't implement my algorithm yet. So I will look around as you suggested. In the meantime if you have any links in mind, please post.
Post a Comment