I'm trying to take an ongoing chess game and use image recognition to automatically transcribe it into a list of chess moves (1. e4 e5 2. Nf3 Nc6), automatically.
Given a 2D layout of the board and pieces, and standard images for each of the pieces, how would I go about in Java doing this?
Thanks!
I would imagine that depending on the set being played with, given a top down view of the board, it might prove difficult to distinguish between the different pieces.
Rather than relying on image recognition to determine which pieces are which, it would almost certainly be easier to simply track the pieces throughout the course of the game. You already know exactly where they started from, so after each turn it should be possible to deduce which square is now empty that wasn't previously empty, and which square is now occupied that wasn't previously occupied. This makes your image analysis much simpler as you're just determining whether each square on the board is empty or not.
Well if you have an image for each piece than just follow and save(using some arrays) all the moves. But first show us some code on what you have. More info.
For image classification in JAVA you can try Rapidminer and IMMI extension for image mining:
http://spl.utko.feec.vutbr.cz/en/component/content/article/46-image-processing-extension-for-rapidminer-5
For this purpose you should extract global features from images and than train some classifier (e.g. SVM). Another approach might be training Viola-Jones detector.
Related
I've not found anything here or on google. I'm looking for a way to identify shapes (circle, square, triangle and various other shapes) from a image file. Some examples:
You get the general idea. Not sure if BoofCV is the best choice here but it looks like it should be straightforward enough to use, but again I know nothing about it. I've looked at some of the examples and I though before I get in over my head (which is not hard to do some days), I thought I would ask if there is any info out there.
I'm taking a class on Knowledge Based AI solving Ravens Progressive Matrix problems and the final assignment will use strictly visual based images instead of the text files with attributes. We are not being graded on the visual since we only have a few weeks to work on this section of the project and we are encouraged to share this information. SOF has always been my go to source for information and I'm hoping someone out there might have some ideas on where to start with this...
Essentially what I want to do is detect the shapes (?? convert them into 2D geometry) and then make some assumptions about attributes such as size, fill, placement etc, create a text file with these attributes and then using that, send it through my existing code based that I wrote for my other projects to solve the problems.
Any suggestions????
There are a lot of ways you can do it. One way is to find the contour of the shape then fit a polygon to it or a oval. If you git a polygon to it and there are 4 sides with almost equal length then its a square. The contour can be found with binary blobs (my recommendation for the above images) or canny edge.
http://boofcv.org/index.php?title=Example_Fit_Polygon
http://boofcv.org/index.php?title=Example_Fit_Ellipse
I want an efficient way to finding out sub-images from a Image for Ex. we have a image of country map and it contain states as sub-image.
Then i need a way to finding out sub-images of states from country map.
If you have only pixels, you'll need image processing algorithms to find sub-images.
Your solution will be specific to what the image you are processing looks like. For example, if states are outlined in a certain color, you could try edge detection. If states are each different colors, you could run a flood fill like algorithm to create boundaries for each state.
This is a difficult problem. Try computer vision or object recognition for keywords in your research.
However, I suggest instead you build up vector files which define boundaries of subimages by hand. If you've only a few to do, this isn't a big deal.
I want to algorithmically specify every pixel on the screen (full screen) or window to paint in a Java application. I want to do an animation this way.
So, for each pixel, I'll run some type of calculation to determine what color it should be. I'll do this every frame for every pixel.
What is the highest performance (capable of highest frames per second) way to do that?
I understand graphics cards are programmable, but I'd like to stick with just coding in Java for this. If there is a straightforward way to code the algorithms in Java such that they run on the graphics card, that would be great, but I want a solution that does not involve another programming language (which I think OpenCL or such does).
I've done this type of animations before using a the PixelGrabber and MemoryImageSource combination. Here you have some documentation and samples.
Thats the technique with best performance I know. You usually work in the pixel array (do the frame animation transformations) and then render the pixels in the resulting image (Don't need to invoque getPixel/setPixel methods to set individual pixels, which, in old times, was a great optimization).
Don't have any code sample of my own right now, but I can provide one later if you're interested in using this.
As a side note, old editions of the book Java The Complete Reference make plenty use of this techique for image manipulation examples.
I'm working on small project which requires: Change clothes (shirt/pants etc.) of a person in any 2D image he chooses to upload. So somehow edges needs to be detected and relevant areas are supposed to be filled with new patterns. I do see a lot of other complications, but let's assume simple patterns have to be filled only.
For a web application, is it possible to do it in HTML5? Any other alternatives?
For a standalone application, what kind of technology would be preferred, C++/Java?
Update
Based on Bart's comment:
Any useful pointer like Bart's would be really useful
Assumption: Clear traceable 'standing' human figure in 2d image
Since it's an image, there is no real-time scenario
Assumption: Clear traceable 'standing' human figure in 2d image
A way to do this is to require the user to take two pictures. One picture is the one with the user in it, the other picture must be taken in the same camera position and orientation, but the user steps out of the frame for that one.
Since both pictures will have the same background you can compare pixel by pixel between the two images and flag those pixels that have a difference over some threshold. Of course the threshold must be selected so that camera noise isn't detected as a difference. Once you have the collection of pixels that are different you can filter them and calculate an approximate silhouette for the user from the pixels on the edge.
A simplification of the above method can be done if you have control over the background. You could use a bluescreen to avoid having to have a second picture with the background.
Here’s my task which I want to solve with as little effort as possible (preferrably with QT & C++ or Java): I want to use webcam video input to detect if there’s a (or more) crate(s) in front of the camera lens or not. The scene can change from "clear" to "there is a crate in front of the lens" and back while the cam feeds its video signal to my application. For prototype testing/ learning I have 2-3 images of the “empty” scene, and 2-3 images with one or more crates.
Do you know straightforward idea how to tackle this task? I found OpenCV, but isn't this framework too bulky for this simple task? I'm new to the field of computer vision. Is this generally a hard task or is it simple and robust to detect if there's an obstacle in front of the cam in live feeds? Your expert opinion is deeply appreciated!
Here's an approach I've heard of, which may yield some success:
Perform edge detection on your image to translate it into a black and white image, whereby edges are shown as black pixels.
Now create a histogram to record the frequency of black pixels in each vertical column of pixels in the image. The theory here is that a high frequency value in the histogram in or around one bucket is indicative of a vertical edge, which could be the edge of a crate.
You could also consider a second histogram to measure pixels on each row of the image.
Obviously this is a fairly simple approach and is highly dependent on "simple" input; i.e. plain boxes with "hard" edges against a blank background (preferable a background that contrasts heavily with the box).
You dont need a full-blown computer-vision library to detect if there is a crate or no crate in front of the camera. You can just take a snapshot and make a color-histogram (simple). To capture the snapshot take a look here:
http://msdn.microsoft.com/en-us/library/dd742882%28VS.85%29.aspx
Lots of variables here including any possible changes in ambient lighting and any other activity in the field of view. Look at implementing a Canny edge detector (which OpenCV has and also Intel Performance Primitives have as well) to look for the outline of the shape of interest. If you then kinda know where the box will be, you can perhaps sum pixels in the region of interest. If the box can appear anywhere in the field of view, this is more challenging.
This is not something you should start in Java. When I had this kind of problems I would start with Matlab (OpenCV library) or something similar, see if the solution would work there and then port it to Java.
To answer your question I did something similar by XOR-ing the 'reference' image (no crate in your case) with the current image then either work on the histogram (clustered pixels at right means large difference) or just sum the visible pixels and compare them with a threshold. XOR is not really precise but it is fast.
My point is, it took me 2hrs to install Scilab and the toolkits and write a proof of concept. It would have taken me two days in Java and if the first solution didn't work each additional algorithm (already done in Mat-/Scilab) another few hours. IMHO you are approaching the problem from the wrong angle.
If really Java/C++ are just some simple tools that don't matter then drop them and use Scilab or some other Matlab clone - prototyping and fine tuning would be much faster.
There are 2 parts involved in object detection. One is feature extraction, the other is similarity calculation. Some obvious features of the crate are geometry, edge, texture, etc...
So you can find some algorithms to extract these features from your crate image. Then comparing these features with your training sample images.