View Single Post
  #7   Spotlight this post!  
Unread 23-01-2012, 11:05
Bryscus's Avatar
Bryscus Bryscus is offline
EE, CpE
AKA: Bryce B.
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 1999
Location: Jupiter, FL
Posts: 173
Bryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud of
Re: convexHull in WPILib ??

What I ended up doing is creating a script using the NI Vision Assistant and then generating code going to "Tools" -> "Generate C Code". Unfortunately, this code is pretty heavy and has a lot of extra stuff in it for being able to generate generic code. I looked at the different functions they used and then reimplemented them in my own code. The big one is ParticleAnalysis which just has so much overkill in it. I then created my own struct and populated the elements I wanted.

One hint is to use the NIVisionCVI.chm document to find out what each imaqXXXXX function does. The particle analysis is just done with imaqMeasureParticle() for example. The hardest part is learning what functions to use in what order, and by "exporting" your script to C code you can see what NI does. You can then also use the Vision assistant to pick values for thresholding, particle filtering, or whatever you may want to do and see the results instantaneously.

I was a laborious process to be frank, but it should pay off. C is much less demanding than C++, so the function I created should be just about as streamlined as it can get while still using the nivision library.

Quote:
Originally Posted by r0b0man View Post
I've been looking into this too. I noticed that the ParticleAnalysis structure has variables that describe the center of mass. Is it possible that making a particle analysis report performs the convex hull operation?
If not, I've thought of a simple algorithm for doing it. Since you know the dimensions of the acquired image you also know how many pixels in each direction. After constructing your binary image from a threshold you can just iterate over every pixel in a single row and fill in the areas between the 2 "activated" pixels (since there are only 2 values in a binary image for every pixel).
The convexHull function (imaqConvexHull) does quite a bit actually. Not only does it fill in the holes within a particle but it also REPAIRS EDGES, which I think is quite AMAZING. Manually creating this function could be difficult.


- Bryce

P.S. There a other ways as well, I'm sure.
__________________
The opulence of the front office decor varies inversely with the fundamental solvency of the firm.
Reply With Quote