It is currently Sat Dec 15, 2018 4:26 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 57 posts ]  Go to page 1, 2, 3  Next
Author Message
Offline
 Post subject: Webcam + Go
Post #1 Posted: Wed May 19, 2010 1:06 pm 
Beginner

Posts: 6
Liked others: 0
Was liked: 4
Rank: 100 kyu
Hi,
im currently developing a program that captures a live stream from a webcam and saves the recognized game as sgf file.
Anyone want to give it a try? Its not finished yet but i want to know if its working with other setups (cams, boards, light, etc) than mine.

thats what it looks like
http://www.youtube.com/watch?v=j-_l_dpzQNI

get it here and let me know if its working/crap/lacking features (sorry for the freehoster)
http://www.megaupload.com/?d=YO5ZSWH5

its written in c# so it requires windows (or wine - havent tried that) + .NET 2.0 Framework
also dont pay attention to the move i make, im not a go player myself - i barely know the rules :-)

what you need to do
1. run the program
2. set up the camera. The board should fill the preview window (so dont place board and cam too far apart).
the camera must have a good look at the whole board, so dont place it too low (the angle between camera and pane of the board should be at least 45°).
3. shadows are a bit of a problem. If u use directed light the source should be on the same side as the camera.
But it probably works anyways if the shadows cast are not too sharp/dark
4. Place 4 black stones directly on the corners and wait for the program to make a latching sound.
5. youre free to play. the program makes a sound when it detects a new stone. if it dont make sure you place the stone directly on the line intersection


basti


Last edited by SebastianR on Thu May 20, 2010 8:51 am, edited 2 times in total.

This post by SebastianR was liked by 4 people: Actorios, Chew Terr, Phelan, rubin427
Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #2 Posted: Wed May 19, 2010 1:20 pm 
Honinbo
User avatar

Posts: 8321
Location: Santa Barbara, CA
Liked others: 312
Was liked: 1905
GD Posts: 312
Sebastian, very nice! But at the end it says "this will only work for the first 100 moves or so"
Any chance you can improve it so that it records the entire game (sometimes 300+ moves)?
And have you tested "ko" situations and captures? :) Thanks!
SebastianR wrote:
the angle between camera and pane of the board should be at least 45°
What if the camera is set up directly overhead the board,
i.e. the camera is exactly orthogonal to the plane of the board? That'd be ideal, wouldn't it?
Like they do in Japanese, Korean, and Chinese TV live broadcast of professional games. For example:
www.youtube.com/watch?v=w3qphZ4wzpg


Last edited by EdLee on Wed May 19, 2010 1:30 pm, edited 2 times in total.
Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #3 Posted: Wed May 19, 2010 1:25 pm 
Oza
User avatar

Posts: 2060
Location: Texas
Liked others: 546
Was liked: 171
Rank: KGS 3k
GD Posts: 264
KGS: Chew
Yeah, I'm really interested in this. When you said only the first 100 moves work, do you mean for recording, or do you mean that turning the board can only be re-recognized for the first 100 moves or so?

_________________
Someday I want to be strong enough to earn KGS[-].

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #4 Posted: Wed May 19, 2010 1:40 pm 
Beginner

Posts: 6
Liked others: 0
Was liked: 4
Rank: 100 kyu
I see...that was ambiguous. I meant the automatic board recognition after turning will only work if there are enough of the lines to see (no too many stones placed)
Recording the game should work no matter how many stones are placed. Version 0.9 however will NOT SAVE MORE THAN 50 (or so - I forgot) MOVES.
This is because i havent yet figured out whether to sell it or not. Dont hate me for that :-)

@EdLee
Yes that setup would be optimal. But i didn't expect everyone to be willing to have a cam dangeling over his head while playing. Also if its not fixed there somehow it will not work later on because sooner or later an airblow will move it - causing it to loose the board.

basti

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #5 Posted: Wed May 19, 2010 2:14 pm 
Honinbo
User avatar

Posts: 8321
Location: Santa Barbara, CA
Liked others: 312
Was liked: 1905
GD Posts: 312
SebastianR wrote:
i didn't expect everyone to be willing to have a cam dangeling over his head while playing. Also if its not fixed
Yes, it would take some rigging equipment like a tripod
plus something else to firmly fix the camera overhead, and the result would be very nice. :)

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #6 Posted: Wed May 19, 2010 2:20 pm 
Oza
User avatar

Posts: 2060
Location: Texas
Liked others: 546
Was liked: 171
Rank: KGS 3k
GD Posts: 264
KGS: Chew
The easiest thing might be a playstation eye, since it comes with a little mounting platform that would give you a nice angle, and it's USB compatible. Assuming the camera can handle it, but I bet it can. It's essentially designed for that card game that does similar line recognition.

_________________
Someday I want to be strong enough to earn KGS[-].

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #7 Posted: Wed May 19, 2010 2:43 pm 
Site Admin
User avatar

Posts: 1122
Location: Allegan, MI, USA
Liked others: 18
Was liked: 121
Rank: KGS 9k
Universal go server handle: Jordus
SebastianR wrote:
But i didn't expect everyone to be willing to have a cam dangeling over his head while playing.


Answer: Duck Tape camera to forehead. No dangling over the head problem..... :mrgreen:

_________________
I'm thinking...

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #8 Posted: Wed May 19, 2010 3:16 pm 
Gosei
User avatar

Posts: 1449
Liked others: 1562
Was liked: 140
Rank: KGS 6k
GD Posts: 892
There was a thread about this type of thing in GD, I'll find it tomorrow.

_________________
a1h1 [1d]: You just need to curse the gods and defend.
Good Go = Shape.
Associação Portuguesa de Go

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #9 Posted: Wed May 19, 2010 3:27 pm 
Oza
User avatar

Posts: 2060
Location: Texas
Liked others: 546
Was liked: 171
Rank: KGS 3k
GD Posts: 264
KGS: Chew
It's here. http://www.godiscussions.com/forum/show ... ght=camera

This seems more complete and usable, though.

Edit: downloaded it to check it out. Either my webcam wasn't being recognized or I do not know how to properly start recording in the program. My netbook does not have an available resolution setting that will show the whole program, so if there are buttons on the bottom, I cannot select them. Any suggestions for what I need to do?

_________________
Someday I want to be strong enough to earn KGS[-].

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #10 Posted: Wed May 19, 2010 7:51 pm 
Beginner

Posts: 6
Liked others: 0
Was liked: 4
Rank: 100 kyu
@Chew Terr
Ahh thx for the link. Nothing new for me but that GregA outlined the problem pretty well. Although these things are easier said that done :-)
Actually i consider my Program almost finished. But im eager to know if it works for other people.

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #11 Posted: Thu May 20, 2010 1:01 am 
Gosei
User avatar

Posts: 1449
Liked others: 1562
Was liked: 140
Rank: KGS 6k
GD Posts: 892
I'll hook up my webcam and try it when I have some time.

Edit: By the way, does it deal well with wobbling cameras? Imagine someone hitting the table the camera or the board is on, just enough to make it wobble, but not enough to actually dislodge stones.

_________________
a1h1 [1d]: You just need to curse the gods and defend.
Good Go = Shape.
Associação Portuguesa de Go

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #12 Posted: Thu May 20, 2010 8:21 am 
Beginner

Posts: 6
Liked others: 0
Was liked: 4
Rank: 100 kyu
Not sure if wobbling is any different than the rotation i showed in the youtube video.
as long as the program "sees" something that matches the game it has observed before (no known stone may be missing from the view)
nothing is going to happen. if the camera is shaken or fell down or the table moved the program will search (and usually find if the game has not advanced too far)
the board. just make sure the setup parameters are still met.

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #13 Posted: Thu May 20, 2010 9:42 am 
Gosei
User avatar

Posts: 1449
Liked others: 1562
Was liked: 140
Rank: KGS 6k
GD Posts: 892
Cool! I really have to try it then. :)

_________________
a1h1 [1d]: You just need to curse the gods and defend.
Good Go = Shape.
Associação Portuguesa de Go

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #14 Posted: Fri May 21, 2010 2:07 pm 
Beginner
User avatar

Posts: 15
Location: Seattle, WA, USA
Liked others: 0
Was liked: 4
Rank: KGS 8 kyu
Very impressive! I've put my project on a hold a bit as my work has heated up lately, but I plan to put my code up on an opensource site like google code and do some more work on it. I've mostly focused on the problem of automatically detecting a board from a single image, regardless of how many stones are on it - and at as low of an angle as possible. As I'm sure you've noticed, it's not an easy problem. With lots of stones on the board, you have to rely on the edges of the board, and it's easy to find false edges. And at low angle, you have to be very accurate or it is very difficult to accurately find which stones are on which intersection.

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #15 Posted: Fri May 21, 2010 7:50 pm 
Beginner

Posts: 6
Liked others: 0
Was liked: 4
Rank: 100 kyu
Thx greg,
were you successful with that? Right now, I don't have any idea on how to recognize a board full of stones other than brute force.
And because the picture of the board is a "function" of 4 (important) variables (2 rotations and 2 translations) that would take forever.
And additionally, in very low angles half the lines - the horizontal - become useless because they have nothing to do with where the stone is seen. And
in resolutions for realtime image processing they are barely seeable even when the board ist empty. Also the stones become ellipses and when covered by other stones
"in front" of them their form is something even more irregular. I tried my program and it would work with angles as low as 25 to 30 degrees but only when properly set up (with stones in the corner).
But on the other hand, I have only experience with that one approach of detection...
Maybe your good with only taking the two most dominant lines, guessing the camera parameter and interpolating the rest of the grid

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #16 Posted: Sat May 22, 2010 3:31 am 
Gosei
User avatar

Posts: 1449
Liked others: 1562
Was liked: 140
Rank: KGS 6k
GD Posts: 892
GregA wrote:
Very impressive! I've put my project on a hold a bit as my work has heated up lately, but I plan to put my code up on an opensource site like google code and do some more work on it. I've mostly focused on the problem of automatically detecting a board from a single image, regardless of how many stones are on it - and at as low of an angle as possible. As I'm sure you've noticed, it's not an easy problem. With lots of stones on the board, you have to rely on the edges of the board, and it's easy to find false edges. And at low angle, you have to be very accurate or it is very difficult to accurately find which stones are on which intersection.


I've heard of two approaches for this, trying to find the corners and extrapolate stone position, or the opposite, find stones, and extrapolate the board position from it. Have you tried the second?
(disclaimer: I know very little about computer vision algorithms)

_________________
a1h1 [1d]: You just need to curse the gods and defend.
Good Go = Shape.
Associação Portuguesa de Go

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #17 Posted: Sat May 22, 2010 3:51 am 
Beginner

Posts: 2
Liked others: 0
Was liked: 1
Rank: KGS 10 kyu
Hi
I got this thread recommended from a friend. We have written a goboard detection algorithm in a coarse called "statistical image analysis" which does almost the same, but for still images. Maybe we can exchange some ideas.

We use matlab since we are more into math then programming. Our code takes a single image and find the board, gridlines and stones and combine them to find coordinates. Our thought was to use the laptop as a go-clock where you take a picuture from a webcam each time the turn is handed over to the other player.

Our filters are far from optimal and we cannot detect the board in hard backgrounds as in your youtube video where the edges of the table is more distinct then the edges of the board against the table.

I attached a pdf with our basic idea of getting the coordinates.

/Viktor
Attachment:
File comment: Idea of extracting coordinates
flowchart.pdf [466.72 KiB]
Downloaded 809 times


Here is a link to some picture that we used to evaluate the performance. 2 of the pictures taken miss a grid line and therefor generate a wrong board position. 1 Did just get 18 gridlines in one direction detected and therefor crashed. This can be improved and i am trying to figure out how.
http://dl.dropbox.com/u/998131/result.zip


This post by smiladon was liked by: Phelan
Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #18 Posted: Sat May 22, 2010 5:56 am 
Beginner

Posts: 6
Liked others: 0
Was liked: 4
Rank: 100 kyu
Hi smiladon,
nice chart and indeed your separation of edges and lines is something I haven't considered so far. How did you do that? I guess you applied a black top hat filter? Anyways I will try that because the edges and their shadows are the most annoying thing for me right now. Other than that, my board detection works very much like yours. I make a hough transformation get regional maxima and try to combine them to a squared grid. This is done in a quite unmathematical way but its not very sensitive to other edges in the picture.
In detail I start with a bright point and find the brightest neighbor. Then I extend the line by the distance of the two points in both directions, add the brighter "end" and calculate a line closest to the three points (regression) and so on until no more points are found in hough space on that line (i also check that the distance of two points is a somewhat monotone function. In the end I project every point added this way on the regression line. this way I end up with a grid that matches the original quite good. This is neccessary because I use the grid to triangulate camera position and - using camera position and a height for the stones to be placed - project the center of stones that are placed on intersections back to the picture (where i can check if there are color values other than board color in that place).
As you can see that relies heavily on getting the exact (hough) parameters for the grid. Am I right that you also need an almost empty board to detect the grid and cannot infer that from the stones you see? Because otherwise you would not know what line is the closes the the stone (if there are no lines to see). And what about low angles when the brightest point of a white stone is closer to a line that is further away?

I find it quite funny that even this, what might be the easiest task there is in image processing, is causing so much trouble :-)


Added
Nice results. Its working perfectly in the beginning but just like me, fails when the lines are barely visible or totally covered. You might extend the working time by 100 moves or so by interpolating missing lines but in the end there are almost no more lines left to see :-(
By that time one could just consider earlier used parameters fixed and hope for the best but thats not satisfactory (or satisfying? sorry im no native speaker *g*)

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #19 Posted: Sat May 22, 2010 7:01 am 
Beginner

Posts: 2
Liked others: 0
Was liked: 1
Rank: KGS 10 kyu
filtering the image for edge and board are done with opening and closing operation. Filters were designed by my partner so will cite our report:
Quote:
In order to find the board several different filters were used. First the contrast was adjusted to increase the difference between go-board and background. Second, a closing-filter was used. The closing operation is a morphological dilation, followed by a erosion [matlab-help]. This emphasizes brighter regions of the board and removes small, dark regions entirely.

The third operation was a standard 3x3 averaging filter followed by a 3x3 sobel edge detection filter. Since the closing operation and the averaging filter removed the grid lines on the board, as well as most irregularities, the sobel edge detection filter primarily emphasizes the edges of the go board


and for grid lines
Quote:
The sequence of filters employed in order to find the grid lines of the go board is similar to that which was used to find the edges. From the original image two different images were created. The first was generated by a closing operation and the second by an opening operation, which emphasizes darker regions, such as the black grid lines.

The lines themselves are found by taking the absolute difference between the two filtered images. The result, after applying a threshold using Otsu's method [matlab-help], can be seen in figure [fig-grid].


We dont see any increasing difficulty in finding the board when adding stones. We use the the information of the board edges to limit the search region for grid lines, and it works pretty well even on crowded boards, but as i said it does not work perfect and I are considering ways to improve it.
Attachment:
File comment: Detecting gridlines on a halffull board
Result_2010-05-18-140450.jpg
Result_2010-05-18-140450.jpg [ 95.44 KiB | Viewed 17227 times ]


At the level of stones on the board above it works well in 27 out of 30 images, and i belive i can make it work at even higher rate. The result is good enough for the coarse and therefor i will focus on other task until this semester is over (10 more days), then i might work some more on this project =)

Top
 Profile  
 
Offline
 Post subject: Re: Webcam + Go
Post #20 Posted: Sat May 22, 2010 8:05 pm 
Oza

Posts: 2253
Liked others: 1169
Was liked: 537
smiladon wrote:
img- captured stones: 1 black and 7 white

nice work, but I find it funny that you even bother to count the captured stones from the picture off the board.

they are not needed for the final score, and even if you think you still need them, you can simply count the stones on the board. (and it also doesn't matter the number of moves played, because 1b and 7w stones is the same as 0b and 6w stones in the final score)

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 57 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group