Detect an object in a camera image in C#

28,790

Solution 1

use the free AForge.Net image processing library for this. there's a ton of cool stuff to play with.

Solution 2

You need to perform filters operation and masks on image.

I think there are no simple ways to just fetch object from the image, you need to use edge-detection algorithms, clipping, and set the criteria for valid objects/image.

You can also use image thresholding to detect object. You may want to look at below Image processing library.

  1. Filters API for C, C++, C#, Visual Basic .NET, Delphi, Python
  2. http://www.catenary.com/
  3. CIMG richer than above library however it is written in C++

Solution 3

Use aforge colorfiltering

There are many filtering method provided for c#, mainly I prefer aforge filters, for this purpose they have few filters, they are

* ColorFiltering
* ChannelFiltering
* HSLFiltering
* YCbCrFiltering
* EuclideanColorFiltering

See here

Solution 4

Take a look at: https://github.com/dajuric/accord-net-extensions

The library "joins" the free AForge.NET and Accord.NET library and adds image-processing and object tracking-algorithms. Samples included :)

Solution 5

One of the (I guess many possible) approaches:

  1. Find a filter that "gets/calculates" straight lines (edges, etc.) from a given image.

  2. Now you have the collection (array) of all the lines (xStart,yStart & xEnd,yEnd). You can easily calculate all the line-lengths from the coordinates.

  3. Now, considering that you can always (!) expect "one-biggest-square / rectangle" inside the image, it would be quite easy to find and calculate the wanted-sudoku-rectangle region and crop it from the image to do some further processing.

EDIT: Solving/programming that kind of problems is always challenging BUT really interesting at the same time :).

Share:
28,790
user1877401
Author by

user1877401

Have been coding in HTML, JS and CSS for longer than I care to remember, and C# for almost as long.

Updated on July 17, 2020

Comments

  • user1877401
    user1877401 almost 4 years

    I have an image, taken from a live webcam, and I want to be able to detect a specific object in the image and extract that portion of it to do some further processing.

    Specifically, the image would be of a game board, let's say for the purposes of this question that it's a Sudoku game board.

    My initial approach was to look for contrasting areas and work it out from there, but I seem to end up with a lot of potential edges (many erroneous) and no real clue as to how to work out which ones are the ones I actually want!

    Are there any algorithms, libraries, code samples, or even just bright ideas out there, as to how I would go about finding and extracting the relevant part of the image?