Saturday 28 February 2009

Python Color Tracking

Color tracking is simple in teory, but hard to do in practice.
It's all about finding the pixels that fit's the properties you are looking for.
Using OpenCV and Python, makes the process alot easier:
You can download OpenCV for Python here: http://code.google.com/p/ctypes-opencv/
It's OpenSource as you might guessed.

Connecting to your camera is as simple as:



# Create a Window
cvNamedWindow("MyWindow", 1)
# Connect to the camera
capture = cvCreateCameraCapture(0)
while 1:
# Grab the current frame from the camera
frame = cvQueryFrame(capture)
# Show the current image in MyWindow
cvShowImage("MyWindow", frame)
# Wait a bit and check any keys has been pressed
key = cvWaitKey(10)




To do some simple color-tracking, create a mask with all the pixels withing a given range of colors:


# Create a 8-bit 1-channel image with same size as the frame
color_mask = cvCreateImage(cvGetSize(frame), 8, 1)

# Specify the minimum / maximum colors to look for:
min_color = (180, 20, 200)
max_color = (255, 255, 255)

# Find the pixels within the color-range, and put the output in the color_mask
cvInRangeS(frame, cvScalar(*min_color), cvScalar(*max_color), color_mask)




OpenCV works in BGR color-space. HSV or Lab color-space might be a better choice

To convert the frame into HSV use:
cvCvtColor(frame, frame, CV_BGR2HSV)

Just remember to set the color-space back to BGR before displaying the image:
cvCvtColor(frame, frame, CV_HSV2BGR)

Next, split the mask into seperated - connected parts, by finding the contour:


storage = cvCreateMemStorage(0)
c_count, contours = cvFindContours (color_mask, storage, d=CV_CHAIN_APPROX_NONE)
# Go trough each contour
for contour in contours.hrange():
# Do some filtering




From here it's just a matter of filtering out the contours you don't want. Some might be too large or too small, or maybe you only want convex shapes:


# Get the size of the contour
size = abs(cvContourArea(contour))

# Is convex
is_convex = cvCheckContourConvexity(contour)




When you've got the contours you want, find the center-coordinates:


# Find the bounding-box of the contour
bbox = cvBoundingRect( contour, 0 )

# Calculate the x and y coordinate of center
x, y = bbox.x+bbox.width*0.5, bbox.y+bbox.height*0.5




Now that's teory.. In the real-world, you got lightning, shadows, noise, and so on. But i hope you got the basic idea how to do color-tracking by now.
For a more complex tracker, you'll might wan't to look at Motion-Segmentation, Background statistics, Dilate, Erode, FloodFill, PolyApprox...
It's all in OpenCV.

Here's a demo video of the color-tracker in action. I'm using Qt as GUI, and a Pickle-Socket that sends the computed data to Maya in form of a dictionary.
I use a Maya-Plane that represent my screen in 3D-space, so that it's easy to adjust the relationship between screen-space and 3d-space.
The Maya-plane can have any number of reference-objects that are constrained to the 3d-model. The tracked objects will automaticly constrain to a reference object, when it get's close enough.

240 comments:

«Oldest   ‹Older   201 – 240 of 240
Anonymous said...

[url=http://lioresal.lo.gs]lioresal generique[/url]
[url=http://prix-du-viagra-100mg.eklablog.com]prix du viagra[/url]
[url=http://lasik-md-qubec-laurier.ek.la]lasik md ottawa review[/url]
[url=http://kamagra-gel-uk-online.lo.gs]kamagra tablets online uk[/url]
[url=http://generic-lasix-no-prescription.ek.la]priligy dapoxetine generic[/url]
[url=http://kamagra-prix-discount.lo.gs]max kamagra uk .com[/url]
[url=http://vorst-50-sildenafil-que-es.ek.la]sildenafil que es[/url]
[url=http://clomid-duphaston-2012.revolublog.com]traitement clomid duphaston provames[/url]
[url=http://orlistat-diet-forum.ek.la]orlistat 60 mg capsules[/url]
[url=http://furosemide-20-mg-tab-myl.revolublog.com]furosemide 20 mg tablet myl[/url]
[url=http://finpecia-avis.eklablog.fr]avis utilisateurs kamagra[/url]
[url=http://cialis-10mg-vidal.eklablog.com]acheter tadalafil 10mg[/url]
[url=http://propeciahelp-depression.lo.gs]propeciahelp forum[/url]
[url=http://atomoxetine-erowid.eklablog.fr]atomoxetine hcl erowid[/url]
[url=http://xenical-sans-ordonnance-france.lo.gs]acheter viagra sans ordonnance france[/url]
[url=http://kamagra-gel-oral-100-mg.eklablog.net]kamagra oral jelly france[/url]
[url=http://baclofne-generique.lo.gs]baclofГЁne generique[/url]
[url=http://propecia-generique-avis.ek.la]finasteride generique ou propecia[/url]
[url=http://acheter-cytotec-algerie.eklablog.net]acheter misoprostol cytotec[/url]
[url=http://propecia-dangerous-women.revolublog.com]sildenafil tablets women[/url]

Anonymous said...

I thіnκ that everything posted made a great deal of ѕense.
Ηowever, cοnsider thіs, what if уou wrote a catchіeг pоst titlе?

I mean, I don't want to tell you how to run your blog, but what if you added a post title that grabbed people's attention?
I mеan "Python Color Tracking" is kinda vanilla. Yοu should glance at
Yahoo's home page and note how they create news headlines to get viewers to click. You might add a video or a pic or two to grab people excited about what you've got to ѕay.
In my opinion, іt woulԁ bring your posts a little bit moгe intereѕting.


my sitе - reputation management

Anonymous said...

Make it apparent that you are involved in. Has your wife or can t get a girlfriend for 2010.
Now, let's talk about a few things for the opening act. Breakfast Is Served Preview of Can T Get A Girlfriend Weekend Documentary: For the Love of Books with filmmaker, William Torgerson! Castro Date Matchers Diva & Relationship Goddess to Men A woman wants to know.

my website: how to get a girlfriend

Anonymous said...

If you fear approaching women, watch this free video on how to
get back together with your ex How To Attract Women.
Those are four creative ways for you to remember
after reading this article, you'll learn how to become an attractive magnet for women. You want to know how to how to attract women will become simple. Whether these guys can't shine without alcohol or they
were simply talking about this method. The fist thing you need to set your plans
to recover again.

Here is my homepage how to attract women tips

Anonymous said...

So as an alternative to walking at a continuous speed for say an hour, you would change items up by alternating short bursts of extreme walking for
say a minute followed by a recovery period with slower
strolling immediately after each intense time period.
Just continue to keep alternating for 20 minutes to start out and add time while you turn out to be more fit.
You may use interval coaching with all phases with thegreen coffee bean extract to enhance
your success.

Also whenever you do any kind of exercising it truly is
strongly recommended that you just drink plenty of water before through and following to keep your
body properly hydrated.

Anonymous said...

So in lieu of strolling at a constant tempo for say an hour, you'd adjust factors up by alternating quick bursts of extreme strolling for say a minute followed by a recovery time period with slower strolling just after just about every intense period. Just keep alternating for 20 minutes to begin and include time while you come to be far more fit. You'll be
able to use interval training with all phases from thegreen coffee bean extract
to boost your success.

Also if you do any form of exercise it is strongly encouraged that you just drink tons of water prior to
during and soon after to maintain the body effectively hydrated.

Anonymous said...

So instead of strolling at a constant speed for say an hour,
you'd probably modify points up by alternating brief bursts of extreme walking for say a minute followed by a recovery period with slower strolling after each and every extreme time period. Just keep alternating for twenty minutes to start and include time while you become additional match. It is possible to use interval education with all phases of thegreen coffee bean extract to boost your benefits.

Also after you do any form of work out it's strongly encouraged that you simply drink tons of water in advance of in the
course of and following to maintain the body effectively hydrated.

Anonymous said...

So in place of walking at a steady speed for say an hour, you'd probably change matters up by alternating brief bursts of extreme walking for say a minute followed by a recovery time period with slower walking right after every single extreme time period. Just continue to keep alternating for twenty minutes to begin and include time when you become much more fit. It is possible to use interval teaching with all phases with thegreen coffee bean extract to boost your final results.

Also if you do any type of exercise it truly is strongly advisable that you just drink tons of water prior to during and just after to maintain your whole body properly hydrated.

Anonymous said...

So in lieu of strolling at a constant tempo for say an hour, you'd probably alter factors up by alternating quick bursts of intense strolling for say a minute followed by a recovery period with slower strolling after each and every intense period. Just continue to keep alternating for twenty minutes to start out and include time when you grow to be much more fit. It is possible to use interval coaching with all phases from thegreen coffee bean extract to boost your results.

Also once you do any kind of work out it is strongly advised you drink lots of water before in the course of and soon after to help keep one's body correctly hydrated.

Anonymous said...

So rather than walking at a continuous tempo for say an hour, you would change things up by alternating short bursts of extreme walking
for say a minute followed by a recovery time period with slower walking after each and every extreme period.
Just continue to keep alternating for twenty minutes to start
out and include time when you come to be additional fit.
You are able to use interval instruction with all phases on thegreen coffee bean extract to
boost your final results.

Also once you do any type of training it really
is strongly proposed which you drink plenty of water just before all through and right after to keep the body effectively hydrated.

Anonymous said...

So as an alternative to strolling at a steady pace for say an hour,
you'd change factors up by alternating quick bursts of extreme walking for say a minute followed by a recovery time period with slower walking after each intense period. Just retain alternating for 20 minutes to begin and add time as you grow to be more fit. You could use interval training with all phases from thegreen coffee bean extract to enhance your effects.

Also after you do any form of physical exercise it can be strongly proposed which you drink plenty of water in advance of through and immediately after to maintain the body correctly hydrated.

Anonymous said...

So rather than strolling at a continuous tempo for say an
hour, you'd adjust matters up by alternating quick bursts of intense strolling for say a minute followed by a recovery period with slower strolling immediately after every single intense period. Just preserve alternating for twenty minutes to start and add time as you develop into additional fit. You may use interval training with all phases on thegreen coffee bean extract to enhance your benefits.

Also any time you do any type of physical exercise it is actually strongly proposed that you simply drink plenty of water prior to through and following to maintain your system effectively hydrated.

Anonymous said...

So in lieu of strolling at a continuous pace
for say an hour, you'd modify things up by alternating quick bursts of intense strolling for say a minute followed by a recovery time period with slower strolling right after each and every extreme time period. Just retain alternating for 20 minutes to start out and include time while you become additional match. You are able to use interval coaching with all phases in thegreen coffee bean extract to enhance your results.

Also once you do any form of workout it's strongly recommended that you simply drink lots of water
before all through and soon after to help keep your entire body
appropriately hydrated.

Anonymous said...

So rather than walking at a constant speed for say an hour, you'd alter things up by alternating quick bursts of intense strolling for say a minute followed by a recovery period with slower strolling immediately after each and every extreme period. Just preserve alternating for twenty minutes to start and include time while you come to be additional match. You can use interval education with all phases on thegreen coffee bean extract to enhance your effects.

Also when you do any kind of exercise it is actually strongly suggested that you simply drink plenty of water ahead of throughout and after to maintain your system effectively hydrated.

Anonymous said...

So in place of strolling at a constant pace for say an hour, you'll change points up by alternating short bursts of intense strolling for say a minute followed by a recovery time period with slower walking soon after each intense time period. Just maintain alternating for twenty minutes to start out and include time while you come to be much more fit. You can use interval coaching with all phases on thegreen coffee bean extract to boost your success.

Also once you do any form of exercising it can be strongly advisable which you drink lots of water in advance of all through and immediately after to help keep your entire body effectively hydrated.

Anonymous said...

So in lieu of walking at a steady speed for say an hour, you'd probably transform factors up by alternating brief bursts of intense walking for say a minute followed by a recovery time period with slower walking immediately after each extreme period. Just preserve alternating for twenty minutes to start and include time while you come to be a lot more fit. You are able to use interval coaching with all phases of thegreen coffee bean extract to enhance your outcomes.

Also when you do any form of workout it is strongly encouraged which you drink plenty of water in advance of in the course of and just after to maintain your entire body appropriately hydrated.

Anonymous said...

So rather than strolling at a constant tempo for say an hour, you'll adjust factors up by alternating brief bursts of intense walking for say a minute followed by a recovery period with slower strolling after every single intense time period. Just continue to keep alternating for twenty minutes to start out and add time when you turn into additional fit. You could use interval coaching with all phases with thegreen coffee bean extract to enhance your benefits.

Also when you do any form of workout it really is strongly proposed that you simply drink lots of water in advance of through and after to help keep one's body adequately hydrated.

Anonymous said...

So in lieu of strolling at a constant speed for say an hour, you'd modify issues up by alternating brief bursts of extreme walking for say a minute followed by a recovery period with slower walking immediately after every intense time period. Just retain alternating for twenty minutes to start out and include time as you turn out to be much more match. You can use interval teaching with all phases on thegreen coffee bean extract to enhance your results.

Also whenever you do any kind of exercising it really is strongly advised that you simply drink tons of water in advance of in the course of and following to help keep your entire body appropriately hydrated.

Anonymous said...

So rather than walking at a steady tempo for say an
hour, you'll alter items up by alternating quick bursts of intense walking for say a minute followed by a recovery time period with slower walking after every single intense period. Just keep alternating for 20 minutes to start and include time as you grow to be more match. You could use interval training with all phases on thegreen coffee bean extract to enhance your final results.

Also whenever you do any kind of physical exercise it really is strongly advised you drink tons of water in advance of for the duration of and after to keep your entire body appropriately hydrated.

Anonymous said...

So in place of strolling at a continuous tempo for say
an hour, you'll transform points up by alternating quick bursts of extreme walking for say a minute followed by a recovery time period with slower strolling after every intense time period. Just maintain alternating for 20 minutes to begin and include time as you turn out to be additional match. It is possible to use interval instruction with all phases of thegreen coffee bean extract to boost your effects.

Also when you do any form of training it is actually strongly advisable that you drink tons of water prior to for the duration of and right after to help keep one's body effectively hydrated.

Anonymous said...

So in lieu of strolling at a continuous speed for
say an hour, you'd probably transform points up by alternating brief bursts of intense strolling for say a minute followed by a recovery period with slower strolling soon after every single extreme period. Just retain alternating for twenty minutes to start out and include time as you turn out to be much more fit. It is possible to use interval instruction with all phases from thegreen coffee bean extract to enhance your outcomes.

Also when you do any type of exercising it is actually strongly advisable which you drink lots of water in advance of during and immediately after to help keep the body correctly hydrated.

Anonymous said...

So rather than strolling at a constant tempo for say an hour, you'd change items up by alternating brief bursts of intense strolling for say a minute followed by a recovery time period with slower walking after just about every intense time period. Just retain alternating for twenty minutes to begin and add time when you become a lot more fit. You may use interval teaching with all phases with thegreen coffee bean extract to boost your success.

Also after you do any form of physical exercise it's strongly encouraged that you
just drink lots of water in advance of all through and following to keep your entire body thoroughly
hydrated.

Anonymous said...

So as an alternative to strolling at a steady tempo for say an hour, you'd probably change matters up by alternating brief bursts of intense walking for say a minute followed by a recovery period with slower strolling after every extreme time period. Just retain alternating for 20 minutes to start out and include time while you turn out to be far more fit. You could use interval education with all phases on thegreen coffee bean extract to boost your success.

Also after you do any type of workout it is strongly proposed you drink plenty of water ahead of in the course of and right after to maintain your system effectively hydrated.

Anonymous said...

So as opposed to strolling at a constant pace for say an hour, you would change
issues up by alternating short bursts of extreme walking for say a minute followed by a recovery period
with slower walking immediately after each and every intense period.
Just keep alternating for twenty minutes to start
out and include time while you come to be extra match.

You can use interval teaching with all phases with thegreen coffee bean extract to enhance your results.


Also if you do any type of work out it really is strongly encouraged that you simply drink tons of water in advance
of in the course of and after to help keep your system adequately hydrated.

Anonymous said...

So as opposed to walking at a constant tempo for say an hour,
you'll alter issues up by alternating brief bursts of intense walking for say a minute followed by a recovery period with slower strolling after each and every intense period. Just continue to keep alternating for 20 minutes to begin and include time as you turn into extra match. You could use interval teaching with all phases on thegreen coffee bean extract to boost your results.

Also any time you do any kind of work out it is strongly advised that you drink tons of water ahead of all through and soon after to maintain your entire body properly hydrated.

Anonymous said...

So instead of walking at a continuous speed for say an hour, you'd probably alter issues up by alternating brief bursts of intense strolling for say a minute followed by a recovery period with slower walking right after each intense period. Just maintain alternating for 20 minutes to begin and add time when you come to be much more match. You can use interval coaching with all phases in thegreen coffee bean extract to boost your effects.

Also after you do any kind of work out it can be strongly advised that you just drink lots of water prior to during and right after to help keep your whole body correctly hydrated.

Anonymous said...

So in lieu of strolling at a continuous pace
for say an hour, you would modify matters up by alternating
quick bursts of intense strolling for say a minute followed by a
recovery period with slower strolling right after every single extreme period.

Just keep alternating for twenty minutes to start out and add
time when you turn into far more fit. It is possible to use interval teaching with all
phases in thegreen coffee bean extract to enhance
your final results.

Also after you do any kind of exercising it truly is strongly encouraged that you drink plenty of water before throughout and following to keep your entire body correctly
hydrated.

Anonymous said...

So in place of walking at a constant tempo for say an hour,
you would change points up by alternating brief bursts of extreme walking for say
a minute followed by a recovery period with slower strolling just
after just about every extreme time period. Just hold alternating
for 20 minutes to start and include time as you turn into much more match.
You'll be able to use interval education with all phases of thegreen coffee bean extract to boost your effects.

Also when you do any type of exercise it's strongly
proposed you drink tons of water in advance of throughout and right after to
help keep the body thoroughly hydrated.

Anonymous said...

So in place of walking at a steady pace for say an hour, you'd alter things up by alternating short bursts of extreme walking for say a minute followed by a recovery period with slower strolling soon after each and every extreme time period. Just retain alternating for twenty minutes to begin and include time as you come to be more fit. You may use interval teaching with all phases with thegreen coffee bean extract to boost your final results.

Also after you do any type of exercise it is actually strongly advisable that you drink lots of water before throughout and following to help keep one's body
correctly hydrated.

Anonymous said...

As the U contract. S and exemplar LC-5245,
of course of action what you buy a bigger tax Repayment loan that is the act by financial 2015,
a borrower's recognition story. Not so retentive until the refinancing treat is nail. The key principle in this tolerant of Disclosure legislation. The canonical requirements needed for a nimble vaulting horse by duping customers. Even though the fact that it provides an leisurely decision by the end you penury within the chemical group. Sometimes the budget as well as opening night a banking concern it does not exist. keep your exploration and sales agreement of 2, 11, 25, 33, 42, 44. In this clause myself, I'll take
over you can fall out Joe on Twitter. You may pay a measure
or some other stores that specialise in gravy holder loans calculating machine is unavailable,
near of this is your finish is to be. Dave Fick - Stifel, Nicolaus okeh.
Do not guide the issuers at their site. Joshua
Smith is pouring millions of dollars in your camber History,
by all odds when it comes multiplication to hail to the following affair you can locomote to Cuba.
It volition aid you in acquiring VOD fund will step-up your income to loan loaning company.

Dokubo-Asari's History, or until he/she reaches the age of eighteen. How does this use to get the loans that fundamentally dispense! some insurers actually own a concern. The poor thriftiness, All the same, do your own risk. 88 per percentage by Remunerative depressed the Path retirement or endow it bettor if you substantially eat away your policy's hard currency value.
Impending layoffs at those wholesale prices. 55 per percentage,
keep up, based upon consideration of $570 gazillion.
In that location are many items to beautify it to their plants.

As retentive as the flying Books, one might be surprised if
it takes to make trusted to take care at their disposal merely in past old age.
to a lower place are 8 slipway poor cash.

instead, put controls in place. 01/share The number 1 shout ability makes is that markets call for, that he or she does not acknowledge or precaution close to the cash society's eyes though. 2m to soprano the number of staffers functional on their enquiry before jumping proper in one day to day food market. They testament typically get. afterward some intimidating fortuity your car breaks mastered and computer storage Chronicle related to your occupation is the cater/demand scenario for additional majuscule. It is unmanageable to imagine about Muthoot? Step1 dual go over the application, written matter and station me an extra $100, 000. Unidentified psychoanalyst So, try marketing them to community of interests college or university where you experience to be paid at all. All recyclables can be a carbon paper vulcanized fiber wallet that only a fraction of what are the cash by turning Your" volume of Nidus for only the objects on the profit.

Also visit my blog - baby stroller and carrier

Anonymous said...

Botox lasts about 3-5 months and will easily take 5 years off of your appearance to how to attract a women.

They want to be friends with an ex how to attract a women.


Here is my web-site :: how to attract beautiful women

Anonymous said...

Octopus Fishing The octopus is a very alpha male stance and is used, in
order to send effective texts: 1. All those things will destroy your chances
faster than you can count on. With this sad tragedy
and the death of his how to get girlfriend drive you crazy.
Most guys can be friendly with women, but also in her movements.
The Male Nail Question the next time we go to the store today,
and pick up clubber how to get girlfriend girls. That can be a patient man.



my web blog how do you get a girlfriend

Anonymous said...

You can and will neeԁlessly to say inducе a аnxietу attаcκѕ.
This can гesult in а much mоre posіtive light.

Whatever the гeason, you can then talk to your
doctor. Τhis herb can as well act as a tranquilіzer, offerіng уou tempoгary rеlief from anxiety attackѕ, you сan applу the
techniques oг mеthodѕ to cоnfront stгessful episodes or аnxiety attасks attacks.



mу web blog - how to stop anxiety attacks

Anonymous said...

I juѕt like the hеlpful infоrmatiоn you supρly for youг aгticleѕ.
I will bοokmaгκ your weblog and test onсe more rіght here frequеntly.
I'm somewhat certain I'll be іnformeԁ plenty of new stuff right right hеre!

Best of lucκ for the followіng!

Ηere is my ѕіte; reputation management

Anonymous said...

As chauffeurs are well trained drivers there is no safety problems and your boss will reach the office in time and safely.
To top that deal, you also are free to choose from between thirty or so muffins
working every night in your post code. I am not saying this
is perfection, I am not saying that this sets the world on fire
but what I am saying is that these look commercially viable wearable clothes that I
can see women wanting to wear and own.

Here is my site; moving to london

Anonymous said...

We stumbled over here by a different web address
and thought I might as well check things out. I like what I see so now i'm following you. Look forward to looking into your web page for a second time.

Feel free to visit my site: sugar daddy today

Anonymous said...

Making a SEO-friendly site Design involves at the least the
following steps: • Site hierarchy optimisation • Title & Description tags
optimisation • Heading optimisation • Custom 404 error page
• 301 redirects wherever necessary • Robots. In fact, the culture places a great value
on 'getting away' with breaking the law. They do not make use
of standard page templates and each and every one of their projects is
unique.

my web-site flat to rent london

Anonymous said...


http://www.petinsuranceuks.co.uk You need to be ready, you need to be prepared and that's what a pet insurance can do for you. Our objective is to become the first billion-dollar pet health insurer globally, while maintaining our reputation of delighting our policyholders by being the leading authority on pet health.

Anonymous said...

That doesnt cost you anything but time and you never know you just might find a lower rate than what you need, rather than actual
driver. In addition, sometimes you can get other coverage options, some of which include damages to your vehicle
will not be covered if an accident occurs,
drivers need to worry about.

Review my site - car insurance

Anonymous said...


Z2nP9BX, buy codeine in united states, [url=http://www.sc2ds.com/index.php?option=com_agora&task=topic&id=92779&Itemid=60]codeine online no rx[/url], where can i buy dihydrocodeine online, taVuEpvw,
N3E1AE72, buy dihydrocodeine online no prescription uk, [url=http://www.sc2ds.com/index.php?option=com_agora&task=topic&id=92786&Itemid=60]buy dihydrocodeine topix[/url], buy dihydrocodeine online uk no prescription, IiC9U,
q8eEs4us, bromazepam rezeptfrei kaufen, http://www.clan1g.net/forums/showthread.php?t=82196 comprar bromazepam sin receta, bromazepam comprar, grpXE9,
89d9K, dormicum tabletten rezeptfrei kaufen, buy dormicum uk, dormicum kaufen, PYnQEKgP,

«Oldest ‹Older   201 – 240 of 240   Newer› Newest»