Name: Michael Shimniok
Member since: 2007-12-23 16:33:37
Last Login: 2013-08-22 04:57:14
Author of Bot Thoughts blog, interested in robotics since '89. Since 2007, dove in full force, built Pokey the firefighter (failure = learning), and then Data Bus, 3rd place in 2012 AVC, my Rapsberry Pi tele-rover, a beam robot, and have tinkered with lots of other electronic thingies.
Recent blog entries by shimniok
OpenMV: Counting Pips on Dice
One of our backers, Damage, had a great project idea for OpenMV Cam: count a dice roll visually. Here's what I ended up with.
I used simple blob detection. What ended up working best was to first find the white dice (I had no real dice; these are paper cutouts).
To look for color blobs you supply the threshold() function with a color, an RGB value, and a "distance" value (how close a pixel is to the specified color). Behind the scenes this is based on LAB colorspace and euclidean distance between colors.
bin = image.threshold([(160, 210, 255)], 20)
|Note the dice are actually bluish-white|
# image closing
# Find white dice
dbin = image.threshold([(160, 210, 255)], 20)
# image closing
# find dice
dice = dbin.find_blobs()
# Draw rectangles around detected dice
for d in dice:
Now to find the pips. Same process all over again, only this time, the color is sort of a bluish black. I had to experiment with the color and the dilate/erode calls to get it working.
# Find pips in dice blobs
binary = image.threshold([(40, 60, 110)], 25)
# Image closing
# Detect blobs in image
blobs = binary.find_blobs()
Finally, go through all the pips and count the ones that are inside the bounds of the white blobs, the dice. Then display the numbers in the corners of the dice and the total at the bottom. The find_blobs() function returns a list of (x, y, width, height) for each blob.
# Count pips
pips = 0
for d in dice:
dr = (d, d, d+d, d+d)
subpips = 0
for p in blobs:
pr = (p, p, p+p, p+p)
if pr > dr and pr < dr and
pr > dr and pr < dr:
subpips += 1
image.draw_string(d-8, d-8, str(subpips),
(50, 255, 50))
pips += subpips
image.draw_string(55, 120, "total="+str(pips),
(50, 255, 50))
And that's all there is. It works pretty ok for having spent very little time on it. There's some room for improvement. More tuning might help. Better lighting. Real dice. Also, when you roll a 6, it merges adjacent pips.
That's because the firmware normally ignores blobs that are too small. Small blobs next to each other can only be detected if you dilate() enough to make them bigger than the threshold, but that merges them because they're close together. We just have to lower the blob size threshold, I think.
Also, we might get more accurate detection by refactoring threshold() to take separate parameters for color and lightness thresholds.
Meanwhile, OpenMV Cam's Kickstarter ends Feb 25. If you want one click here.
OpenMV Cam, Final Week
|OpenMV Cam, 1.8" x 1.4", final week on Kickstarter|
Wait. Python? Yes, it runs Micro Python on the module.
That means with some simple Python scripts, your project can detect and track a human face, or an object, or you can track multiple colored objects of different colors, you can take a picture, record movies, interface with UART, SPI, I2C, control servos and more.
For NoCo Mini-Maker Faire, I set up a demo with my red Magician robot rotating to track a yellow object (placed on my Pololu 3pi). I tweaked the color tracking script in a few minutes to output the blob coordinates over serial to the PIPduino controlling the Magician, then wrote the Arduino code in another few minutes to spin in place based on blob position. Then tuned the color matching, et voila:
As for shields, we now have a thermopile array sensor shield available. We're working on a WiFi shield, LCD Shield, and a few others for later release.
|IR / Thermopile bundle: OpenMV Cam plus IR lens, thermopile shield, USB|
With the thermopile shield, based on a 16x4 Melexis MLX90620 sensor, you write a simple python script to overlay a heat map on the camera image as in this demo video (we used an LCD prototype shield here, but you get the idea):
So if you want to join our community, and get yourself an OpenMV Cam at Kickstarter pricing, here's the link to make a pledge: http://bit.ly/OMVKS - we appreciate any support you can offer, thanks!
Add machine vision to projects
Now it's actually easy to add machine vision to projects. How?
With a few lines of Python, OpenMV Cam can track a face, an object, or color, it can record photos or video, and you can expand it with shields. It's small at only 1.8" x 1.4" and affordable.
Learn more on Kickstarter.
Bubble Display, Propeller
|HP 4-Digit Bubble Display (7-Segment LED)|
I used one of my spare eeZee Propellers to play around with the display and create driver code. I haven't played in Spin in awhile, so it was a good refresher. Here's what I did...
Propeller pins P16 - P19 are connected to Cathode 4 through 1, respectively. Pins P20 - P26 are connected to Anode A through G, respectively. The decimal point is hooked up to P27.
Driving 7-Segment Displays
You could simply drive the display one digit at a time, setting all the required anodes high and the corresponding cathode low.
A common cathode display is intended to be controlled with the cathodes. Use 4 resistors, one for each cathode, power each of the common anodes sequentially, and use the cathodes to individually turn segments on or off for each display digit position.
The display driver runs on a cog and displays digits stored in hub memory. The main cog simply counts from 0 to 9999 over and over again, extracting the 1's, 10's, 100's and 1000's place and storing the numbers for display, as follows, where b1, b2, b3, b4 are each of the digits.
PUB Start | i
b1 := b2 := b3 := b4 := 10 ' initial digit (>9 means off)
cognew(display, @stack) ' start display driver cog
repeat i from 0 to 9999
b4 := i // 10 ' ones
b3 := (i/10) // 10 ' tens
b2 := (i/100) // 10 ' hundreds
b1 := (i/1000) // 10 ' thousands
waitcnt(clkfreq/10+cnt) ' count at ~10Hz
I may refactor the program to use BCD; storing digits in each of the 4 bytes of a Propeller's 32-bit long int, but the code is more readable using one variable per digit.
Driver DetailsAs for the driver, a segment array, seg, stores the outa cathode pin bits required to turn on each segment (a through g) at each display digit position (1 through 4).
The main loop calls setdigit(digit, value) which sets the cathode bit in the seg array, for the specified display digit and the specified numeric value. For example, displaying "2" in position 3 requires the cathode for position 3 to be low (on) for segments a, b, d, e, g, and high (off) for segments c and f.
setdigit(1, b1) ' set 1's value
setdigit(2, b2) ' set 10's value
setdigit(3, b3) ' set 100's value
setdigit(4, b4) ' set 1000's value
bit := AN_A ' start with anode a
repeat s from A to G ' loop thru segments
outa := seg[s]|bit ' turn on cathodes, anode
bit <<= 1 ' next anode bit
Then, the main loop iterates over the array, seg[A..G], sets the cathode pins, simply with outa := seg[s] and raises the corresponding segment anode pin for each array element by ORing outa with bit, which is the bit corresponding to the current anode pin. How does the array get set with the right cathode?
The setdigit(digit, value) function converts the display digit into the appropriate cathode bit to activate (set low) or deactivate (set high).
It then uses the numeric value (0..9) in another case statement to select which segments should be on (seg[?] &= set) or off (seg[?] |= unset).
1: unset := CA_1
2: unset := CA_2
3: unset := CA_3
4: unset := CA_4
other: unset := 0
set := !unset & (CA_1|CA_2|CA_3|CA_4)
0: seg[A] &= set
seg[B] &= set
seg[C] &= set
seg[D] &= set
seg[E] &= set
seg[F] &= set
seg[G] |= unset
So, It's Been Awhile...You would have heard from me sooner, but alas, there has not been much time for tinkering or blogging lately.
My paucity of spare time can be blamed on work, filling Tindie orders, and gearing up for the crowd funding campaign for OpenMV Cam.
Holiday Deals for Nerds Like Us
- 15% any one item in the Bot Thoughts Store, coupon code DA54D6C, good through Friday
- $2 off Digispark - Lowest Price Ever! Digispark! The micro-sized, Arduino enabled, usb development board - cheap enough to leave in any project! Coupon 9D4B1F3
- 30% off PiScreen is a 3.5" TFT (480x320) with touchscreen control for the Raspberry Pi. Never need a monitor again! Coupon 02971ED
- 20% off much of the Arachnid Labs' Store - including the successful Kickstarter, Re:Load Pro. Coupon 21A2FD3
- 15% off all products in the Geppetto Electronics store! Coupon 92C9FC5
- And lots more on sale; full list here
E-Z Robot Black Friday : 20% off all robot kits + free shipping!
Science Fiction inspired robots that don't require programming (unless you want too)! In 1977, the world invited the Apple II Personal Computer into the home. 2014, ezrobot has launched Revolution, a robot for everyone! Whether you choose the Revolution clip'n'play robots or developer kit, ezrobot is making robotics, well... easy!
HobbyPartz Black Friday Sale: 15% off select items including Gens Ace batteries.
Coupon code BFSALE15, ends Nov 30, 11:59PM. Sale on LiPo batteries, RC gear, video cams, and more.
Schmartboard Black Friday : 25% off the entire store! Limited time.
RoboSavvy Black Friday : 50 products with savings up to 67%
Adafruit Black Friday : 15% off plus free stuff.
Welcome to the Black Friday sale – 15% off plus all the free items & shipping as you shop! Use code: BLACKFRIDAY on check out. We thought about doing flash sales or complicated codes but that’s a lot of frustrating hoop jumping for everyone, so we came up with what we think is an amazing deal that is straight forward, no stress and valuable – a 15% off discount anything in stock and lots of great free things automatically depending on how much you order.
We are currently offering a FREE Adafruit Perma-Proto Half-sized Breadboard PCB for orders over $100, a FREE Trinket 5V for orders over $150, FREE UPS ground (Continental USA) for orders $200 or more, a FREE Pro Trinket 5V for orders over $250
Sparkfun Cyber Monday 2014 : 20% off Actobotics, hourly flash sales 7am - 7pm
GHI Electronics: Black Friday through Cyber Monday sale on FEZ MCU boards and more!
The sale will start this Friday, November 28th and will end Monday, December 1st (UTC-05:00) Eastern Time (US & Canada). Lots of great boards on sale including discontinued models.
Black Friday / Cyber Monday is here at Trossen Robotics! Interbotix & RobotGeek brand kits and parts are 20% off, everything else in the store is 10% off! Use coupon code "Friday14" to redeem your discount at checkout! Offer good from 12/28/2014 - 12/1/2014 *Offer excludes HR-OS1 and HR-OS5 Humanoid Platforms.
HobbyKing Cyber Week Sale: LiPos, servos, motors, planes, and more.
Running all week, we will be dropping prices and offering amazing deals on literally hundreds of the most popular items in the HobbyKing catalog. Models, lipos, tools, chargers, we'll be offering amazing discounts from all product categories, so you're almost guaranteed to pick up an amazing deal. If you don't see something you are interested, check back in an hour because our offers will be added and changed constantly. This isn't a week where you want to be away from an internet connection.
Electronics Goldmine : has a few door busters and some discounts worth looking at.
Drone Life : has a list of drone sales, too
Others have certified shimniok as follows:
[ Certification disabled because you're not logged in. ]