I am attempting to map out social networks
For example, i have person A and he has 5 followers, these followers and the person would be represented by a vertex, and then have an edge connecting them. And most likely, at least half of them are following each other, creating a big sort of "web".
I tried doing this in QuickGraph, however i ran into a few issues:
The graph ends up looking like more like a flow chart then a web, example from earlier in QuickGraph:
When i test with real data, the graph just becomes a huge, laggy, spaghetti mess of ink
What would be the best way to create this sort of graph?
For reference i am looking to make a graph that looks like this:
So the data structure you are working with is a Directed Graph - that is, the edges of your node have a direction, from follower to followed.
It looks like you are using dot to render your graph, which is a great way to lay things out if your data has some kind of start and end - if there is an overall sense of earlier to later, sources to sinks, simpler to more complex.
You don't really have that, and your example picture is more typical of an undirected graph. The same people that do dot also do neato, which gives you diagrams much closer to your desired picture.
I don't know QuickGraph's API at all, but I'd look to either;
change the graph data structure you're creating -- try switching to something like UndirectedGraph and see if that ends up switching the render
see if there are options in your render method to render an undirected graph rather than a directed graph.
Related
I'm trying to perform image registration without much luck.
The image below is my 'reference' image. I use a webcam to acquire images of the same object in different orientations and then need to perform a transformation on these images so that they look as close to the reference image as possible.
I've been using both the Aforge.NET and Accord.NET libraries in order to solve this problem.
Feature detection/extraction
So far I've tried the image stitching method used in this article. It works well for certain types of image but unfortunately it doesn't seem to work for my sample images. The object itself is rather bland and doesn't have many features so the algorithm doesn't find many correlation points. I've tried two versions of the above approach, one which uses the Harris corner detector and one which uses SURF, neither of which has provided me with the results I need.
One option might be to 'artificially' add more features to the object (i.e. stickers, markings) but I'd like to avoid this if possible.
Shape detection
I've also tried several variations of the shape detection methods used in this article. Ideally I'd like to detect the four well-defined circles/holes on the object. I could then use the coordinates of these to create a transformation matrix (homography?) that I could use to transform the image.
Unfortunately I can't reliably detect all four of the circles. I've tried myriad different ways of pre-processing the image in order to get better circle detection, but can't quite find the perfect sequence. My normal operations is:
turn image grayscale
apply a filter (Mean, Median, Conservative Smoothing, Adaptive Smoothing, etc)
apply edge detection (Homogenity, Sobel, Difference, Canny, etc)
apply color filtering
run shape/circle detector
I just can't quite find the right series of filters to apply in order to reliably detect the four circles.
Image / Template matching
Again, I'd like to detect the four circles/holes in the object, so I tried an image / template matching technique with little success. I've created a template (small image of one of the circles) and run the Exhaustive Template Matching algorithm, without much success. Usually it detects just one of the holes, usually the one the template was created from!
In summary
I feel like I'm using the correct techniques to solve this problem, I'm just not sure quite where I'm going wrong, or where I should focus my attention further.
Any help or pointers would be most appreciated.
If you've added examples of transformations you're trying to be invariant to - we could be more specific. But generally, you can try to use HOG for detecting this structure, since it is rather rich in gradients.
HOG is mostly used to detect pedestrians, besides it is good for detecting distinct logos.
I am not sure about HOG's invariance to rotations, but it's pretty robust under different lighting and under moderate perspective distortion. If rotation invariance is important, you can try to train the classifier on rotated version of object, although your detector may become less discriminative.
After you have roughly detected the scale and position of your structure - you can try to refine it, by detecting ellipse of it's boundary. After that you will have a coarse estimate of holes, which you can further refine using something like maximum of normalized cross correlation in this neighbourhood.
I know it's been awhile but just a short potential solution:
I would just generate a grid of points on the original image (let's say, 16x16) and then use a Lucas-Kanade (or some other) feature detector to find those points on second image. Of course you likely won't find all the points but you can sort and choose the best correlations. Let's say, the best four? Then you can easily compute a transformation matrix.
Also if you don't get good correlations on your first grid, then you can just make other grids (shifted, etc.) until you find good matches.
Hope that helps anyone.
Despite Googling around a fair amount, the only things that surfaced were on neural networks and using existing APIs to find tags about an image, and on webcam tracking.
What I would like to do is create my own data set for some objects (a database containing the images of a product (or a fingerprint of each image), and manufacturer information about the product), and then use some combination of machine learning and object detection to find if a given image contains any product from the data I've collected.
For example, I would like to take a picture of a chair and compare that to some data to find which chair is most likely in the picture from the chairs in my database.
What would be an approach to tackling this problem? I have already considered using OpenCV, and feel that this is a starting point and probably how I'll detect the object, but I've not found how to use this to solve my problem.
I think in the end it doesn't matter what tool you use to tackle your problem. You will probably need some kind of machine learning. It's hard to say which method would result in the best detection, for this I'd recommend to use a tool like weka. It's a collection of multiple machine learning algorithms and lets you easily try out what works best for you.
Before you can start trying out the machine learning you will first need to extract some features out of your dataset. Since you can hardly compare the images pixel by pixel which would result in huge computational effort and does not even necessarily provide the needed results. Try to extract features which make your images unique, like average colour or brightness, maybe try to extract some shapes or sizes out of the image. So in the end you will feed your algorithm just with the features you extracted out of your images and not the images itself.
Which are good features is hard to define, it depends on your special case. Generally it helps to have not just one but multiple features covering completely different aspects of the image. To extract the features you could use openCV, or any other image processing tool you like. Get the features of all images in your dataset and get started with the machine learning.
From what I understood, you want to build a Content Based Image Retrieval system.
There are plenty of methods to do this. What defines the best method to solve your problem has to do with:
the type of objects you want to recognize,
the type of images that will be introduced to search the objects,
the priorities of your system (efficiency, robustness, etc.).
You gave the example of recognizing chairs. In your system which would be the determining factor for selecting the most similar chair? The color of the chair? The shape of the chair? These are typical question that you have to answer before choosing the method.
Either way one of the most used methods to solve such problems is the Bag-of-Words model (also Referred the Bag of Features). I wish I could help more but for that I need that you explain it better which are the final goals of your work / project.
I'm wondering what way would be best to render a 2D map for a shooter (these will be static maps) similar to Soldat. Multiple options I've considered are a tile based map (stored in txt files), or just creating different classes for the different terrains I plan to use and creating a data structure to read/store them in a file. (I want to also be able to include things like jumping/running on walls, sliding down walls/slopes ect)
I feel like there must be a better way than either of these, but haven't been able to find definitive information :/
Thanks :)
Soldat used a polygon based format to render and represent it's levels. The editor would have allowed the user to plot points and connections between them to make walls and structures when were then given textures and properties (such as collide = death). Items and images where then overlayed over this.
The soldat rendering engine would then use these structures to perform collision detection and to build up the polygon (triangles that are drawn) representation of the world.
I was going to go with the "just use a tile map," but then I looked at Soldat and it's a bit more complex.
I don't know what they're using, but I suspect they're using polygons and probably colliding against polygons as well. The levels are likely generated with the same sort of primitives you'd see in 3D games, but all in a plane. E.g. texture mapped triangles and collision against the edges of the surfaces rather than against the surface itself.
In my experience, "terrain" is usually an object in itself and the collision and visual representations are data inside that object (aggregated into that object, typically). The different pieces of terrain don't necessarily need to be different types of thing, indeed in all of the games I've made the entire world was generally a single object of type "Terrain" or "World" or something and it managed the doings of the various visible pieces coming into and out of view.
This doesn't feel like a great answer, but I thought I'd try to give you something.
Examples of platform games doing what you want are Braid and Aquaria. You can get Aquaria for 2 pennies litteraly, with the Humble Indie Bundle.
Here's the Aquaria's editor in action. I could not find a decent video of the Braid editor.
I found this other video about IndieLib, and a level editor that they have created which is similar to Aquaria's (Disclaimer: I haven't tried it myself).
Appart from that, googling for "Braid and Aquaria platform engine" should give you more results.
I would recommend reading the book Building XNA 2.0 Games: A Practical Guide for Independent Game Development. It walks you through the development of a 2D side-scoller game named Zombie Smashers (based on the author's award-winning The Dishwasher: Dead Samurai).
Chapter 4: The Map Editor is what you are looking for.
It will help you even if you don't plan on developing in XNA.
I've been reading about using the winged-edge data structure for storing a boundary representation. However, the linked site says that this is one of the oldest data structres for storing b-reps, are there newer better ones?
Secondly, is there an implementation of this in C#?
The datastructure used for a B-rep is very similar to those used for polygonal modeling - you just replace the edges with curves and the faces with surfaces.
The wikipedia page on polygonal meshes has several types listed, including winged edge. Personally I like half-edge meshes. The only thing they can't do well is non-manifold topology, which you may or may not need. If you do, look for radial edge topology.
There's also a freely available B-rep datastructure from OpenNurbs (McNeel, the makers of Rhino). That also gets you file IO, which is nice.
Boundary Representation Modelling Techniques by Ian Stroud will give you a survey of ways people have approached B-reps, along with a plethora of diagrams with all the Euler operators, and concrete data structures and algorithms for implementing B-reps imperatively.
Whether you want to move a few characters forward into F# or not, you may glean quite a bit of info from the source code for Wings3d (written in Erlang). Just don't get lost making spaceships and forget you were supposed to be coding!
Also the GML will allow you to investigate interactively what you can do with your B-reps, and the data structure is the code.
Not sure if this will help or not but there are Geometry objects in the XNA library for dealing with 3D Structures and what not. There may be something in there. However my guess is that it will either be Point based or Triangle based vs edge based.
But it might be a place to look.
this is a totally unfamiliar area for me. can anyone point me in the right direction on how to create a social graph and the best way to represent it? i'm building a website in C#/asp net and need to create a "friends" feature... is this type of thing usually stored entirely in the DB? if so, how?
Is your primary concern painting a picture of the social network or storing the data?
For storage you might consider a graph database. However, the most mature product in this space is neo4j, which has the name suggests is written in Java. This SO discussion list some alternative approaches for .Net.
edit
You are still not being clear whether you need design advice or code samples. Andrew Siemer wrote a two-part article which outlines the issues and then presents some ASP.net code. I don't think it's by any means a complete solution but it could give you a steer in the right direction.
Your question is rather open-ended. For drawing complex graphs, one of my favorite tools is Graphviz. Graphviz can work with directed or non-directed graphs. It can take the input as a simple text file, and then output the graph in a variety of formats.
So your problem is primarily a data storage issue, and how to store and retrieve edges in your graph. Applying some simple graph terms to your problem:
Node/Vertex: In your case each person will represent a node.
Edge/Link: The relationship between nodes, in this case 'friends', will create an undirected edge between two nodes.
So you will need to maintain a data structure in your DB that allows you to resolve the edge relationships between friends.
Some useful information can probably be found in this question:
challenge-how-to-implement-an-algorithm-for-six-degree-of-separation
Also, something you should consider when deciding how to store your edge list is how many edges you think your site will generate. This will probably effect the storage mechanism you decide on.
Hope those pointers help.