<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>Lirtex - Technology on the Edge of Time</title> <atom:link href="http://www.lirtex.com/feed/" rel="self" type="application/rss+xml" /><link>http://www.lirtex.com</link> <description>Software, Hardware, Robotics, Engineering</description> <lastBuildDate>Sat, 04 Feb 2012 00:15:48 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Microcontroller In Circuit Serial Programming (ICSP) with Microchip PIC and Atmel AVR</title><link>http://www.lirtex.com/embedded/microcontroller-icsp-in-circuit-programming/</link> <comments>http://www.lirtex.com/embedded/microcontroller-icsp-in-circuit-programming/#comments</comments> <pubDate>Fri, 03 Feb 2012 21:48:17 +0000</pubDate> <dc:creator>Lior Chen</dc:creator> <category><![CDATA[Embedded]]></category> <category><![CDATA[AVR]]></category> <category><![CDATA[Electronics]]></category> <category><![CDATA[ICSP]]></category> <category><![CDATA[Microcontroller]]></category> <category><![CDATA[PIC]]></category><guid isPermaLink="false">http://www.lirtex.com/?p=457</guid> <description><![CDATA[In Circuit Serial Programming is a method of directly programming a Microchip PIC or Atmel AVR while in they are connected to a circuit, as opposed to programming the chip ahead, and only then soldering it to a circuit. There are many benefits to ICSP, but also some important design considerations which I will try [...]]]></description> <content:encoded><![CDATA[<p>In Circuit Serial Programming is a method of directly programming a Microchip PIC or Atmel AVR while in they are connected to a circuit, as opposed to programming the chip ahead, and only then soldering it to a circuit. There are many benefits to ICSP, but also some important design considerations which I will try to highlight.<br /> <a href="http://www.lirtex.com/wp-content/uploads/2012/02/PIC_ICSP_4801.jpg" rel="lightbox[457]" title="PIC microcontroller ICSP (in circuit programming)"><img class="aligncenter" style="border-style: initial; border-color: initial; border-image: initial; border-width: 0px;" title="PIC microcontroller ICSP (in circuit programming)" src="http://www.lirtex.com/wp-content/uploads/2012/02/PIC_ICSP_4801.jpg" alt="" width="480" height="380" /></a></p><p><span id="more-457"></span></p><p>In circuit programming has many advantages:</p><ul><li>It shortens the development cycle &#8211; it is really annoying to take a chip out of the board each time it needs to be reprogrammed, and it&#8217;s even <strong>much</strong> harder with SMD.</li><li>Allows customer and in field firmware upgrades</li><li>Calibrate the system during manufacturing or in the field</li><li>Assign unique ID \ serial number to product</li></ul><h2>How to prepare your circuit to work with ICSP?</h2><p>The programmer uses serial signaling scheme to program the chip in circuit. The signaling is carried through the <em>programming clock </em>(PGC or ICSPCLK) and the <em>programming data (PGD or ICSPDAT) </em>pins. In addition, the MCLR/VPP pin is used as either a high voltage programming signal or an attention indicator to the device.</p><p>Wherever application allows, <span style="text-decoration: underline;">use dedicated pins for ICSP</span>. It will save you much trouble. Not sharing a pin both for ICSP and I/O for example, minimizes the preparation work which needs to be done to allow ICSP.</p><p>Often, and especially true with low pin devices, it is not possible to dedicate the 3 needed pins just for ICSP, and when want them to have dual functionality.</p><p>In this case:</p><p>1. Isolate Vpp from the circuit by using a Schotkey diode and an R/C. <span style="color: #ff0000;">NOTE:</span> in some devices, like the PIC12F629, this pin will be driven to about 13 volts by the programmer while programming the device. Make sure whatever is connected to the Vpp pin can sustain this voltage level, or isolate it with an appropriate resistor or a Schotkey diode.</p><p>2. Isolate ICSP_Clock and ICSP_Data from the rest of the circuit. The isolation method is <span style="text-decoration: underline;">application specific</span>, which unfortunately means there is no ready recipe.  Often, a resistive isolation works fine. Recommended resistor values are 1k to 10k.</p><p>3. Physically locate the ICSP header as close as possible to the programmed chip, to reduce attenuation.</p><p><img src="/images/electronics/MultiPicProgrammer/ICSP_Connection_Diagram.png" alt="ICSP Connection Diagram" width="725" height="305" border="0" /></p><h2>Common Microchip PIC ICSP layouts</h2><p><a href="http://www.lirtex.com/wp-content/uploads/2012/02/PIC-ICSP-connection-diagram.jpg" rel="lightbox[457]" title="PIC-ICSP-connection-diagram"><img class="aligncenter size-full wp-image-461" title="PIC-ICSP-connection-diagram" src="http://www.lirtex.com/wp-content/uploads/2012/02/PIC-ICSP-connection-diagram.jpg" alt="" width="640" height="355" /></a></p><h2>Additional reading and references</h2><ol><li><a href="http://ww1.microchip.com/downloads/en/DeviceDoc/51553B.pdf" target="_blank">Microchip PICKit 2  manual</a></li><li><a href="http://ww1.microchip.com/downloads/en/devicedoc/30277d.pdf" target="_blank">Microchip In-Circuit Serial Programming™ (ICSP™ ) Guide</a></li><li><a href="http://en.wikipedia.org/wiki/In_Circuit_Serial_Programming_(ICSP)" target="_blank">ICSP in wikipedia</a></li></ol> ]]></content:encoded> <wfw:commentRss>http://www.lirtex.com/embedded/microcontroller-icsp-in-circuit-programming/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Fast Object Tracking &#8211; Robot Computer Vision</title><link>http://www.lirtex.com/robotics/fast-object-tracking-robot-computer-vision/</link> <comments>http://www.lirtex.com/robotics/fast-object-tracking-robot-computer-vision/#comments</comments> <pubDate>Thu, 16 Sep 2010 01:17:05 +0000</pubDate> <dc:creator>Lior Chen</dc:creator> <category><![CDATA[Robotics]]></category> <category><![CDATA[Beagleboard]]></category> <category><![CDATA[Computer Vision]]></category> <category><![CDATA[Image Processing]]></category><guid isPermaLink="false">http://www.lirtex.com/?p=173</guid> <description><![CDATA[I wanted my robot to be able to track object and follow them. The first thing I wanted to do is give the robot the ability to follow an object with its head camera. The head camera is mounted on a pan-tilt servo system, and hence is capable of moving left and right, up and [...]]]></description> <content:encoded><![CDATA[<p>I wanted <a href="http://www.lirtex.com/robotics/linux-robotic-platform-an-intelligent-robot/">my robot</a> to be able to track object and follow them. The first thing I wanted to do is give the robot the ability to follow an object with its head camera. The head camera is mounted on a pan-tilt servo system, and hence is capable of moving left and right, up and down (as seen in the picture below).</p><p style="text-align: center;"><a href="http://www.lirtex.com/wp-content/uploads/2010/09/Robot-Front-Camera-mounted-on-a-head-tilt-servo-system.jpg" rel="lightbox[173]" title="Robot Front Camera mounted on a head tilt servo system"><img class="size-medium wp-image-203  aligncenter" title="Robot Front Camera mounted on a head tilt servo system" src="http://www.lirtex.com/wp-content/uploads/2010/09/Robot-Front-Camera-mounted-on-a-head-tilt-servo-system-300x288.jpg" alt="" width="300" height="288" /></a></p><p style="text-align: left;">My second object tracking goal was to make the robot chase after an object, much like a dog would chase a ball thrown by his owner. This kind of tracking is quite harder &#8211; it would use the head camera tracking from the previous step, and combine it with rest of the robot sensors to follow the object.</p><p style="text-align: left;"><span id="more-173"></span></p><h2 style="text-align: left;">How?</h2><p>To achieve that I&#8217;m going to use several basic image processing \ computer vision algorithms. I&#8217;m going to use the <a href="http://opencv.willowgarage.com/wiki/" target="_blank">OpenCV</a> library. OpenCV, as it&#8217;s name suggests, is an open-source computer-vision library originally</p><p>developed by Intel. It is cross-platform (I have used it both on a PC and on the ARM based <a href="http://www.lirtex.com/embedded/choosing-an-embedded-linux-board/" target="_blank">Beagleboard</a>). OpenCV is fairly easy to use if you have basic knowledge in image-processing.</p><p>The first object I wanted to track was a plain colored orange ball.</p><p><a href="http://www.lirtex.com/wp-content/uploads/2010/09/Object-Tracking-Orange-Ball1.jpg" rel="lightbox[173]" title="Object-Tracking-Orange-Ball"><img class="size-thumbnail wp-image-216 alignnone" title="Object-Tracking-Orange-Ball" src="http://www.lirtex.com/wp-content/uploads/2010/09/Object-Tracking-Orange-Ball1-150x150.jpg" alt="" width="150" height="150" /></a></p><h3><strong>Color based tracking</strong></h3><p>Filter only the orange color from the image. To do that, I converted the image to the <a href="http://en.wikipedia.org/wiki/HSL_and_HSV" target="_blank">HSV color-space</a>, and then used the cvInRange filter twice to filter the orange colors.</p><p>In the first picture below you can see the video steam converted to the HSV color space, and in the second picture you can see the result of the red color filtering (all colors except red were filtered out).</p><p><strong><a href="http://www.lirtex.com/wp-content/uploads/2010/09/FastObjectTracking-process-HSV.jpg" rel="lightbox[173]" title="Fast Object Tracking HSV color conversion"><img class="size-medium wp-image-244 alignnone" title="Fast Object Tracking HSV color conversion" src="http://www.lirtex.com/wp-content/uploads/2010/09/FastObjectTracking-process-HSV-300x238.jpg" alt="" width="300" height="238" /></a><a href="http://www.lirtex.com/wp-content/uploads/2010/09/FastObjectTracking-process-Color-Filtering.jpg" rel="lightbox[173]" title="Fast Object Tracking Color Filtering"><img class="size-medium wp-image-245 alignnone" title="Fast Object Tracking Color Filtering" src="http://www.lirtex.com/wp-content/uploads/2010/09/FastObjectTracking-process-Color-Filtering-300x239.jpg" alt="" width="300" height="239" /></a></strong></p><p>(python code)</p><pre class="brush: python; title: ; notranslate">&lt;/p&gt;
&lt;p&gt;#declare necessary objects&lt;/p&gt;
&lt;p&gt;hsv_frame = cvCreateImage(size, IPL_DEPTH_8U, 3)&lt;br /&gt;
thresholded = cvCreateImage(size, IPL_DEPTH_8U, 1)&lt;br /&gt;
thresholded2 = cvCreateImage(size, IPL_DEPTH_8U, 1)&lt;br /&gt;
hsv_min = cvScalar(0, 50, 170, 0)&lt;br /&gt;
hsv_max = cvScalar(10, 180, 256, 0)&lt;br /&gt;
hsv_min2 = cvScalar(170, 50, 170, 0)&lt;br /&gt;
hsv_max2 = cvScalar(256, 180, 256, 0)&lt;/p&gt;
&lt;p&gt;# convert to HSV for color matching&lt;br /&gt;
# as hue wraps around, we need to match it in 2 parts and OR together&lt;br /&gt;
cvCvtColor(frame, hsv_frame, CV_BGR2HSV)&lt;br /&gt;
cvInRangeS(hsv_frame, hsv_min, hsv_max, thresholded)&lt;br /&gt;
cvInRangeS(hsv_frame, hsv_min2, hsv_max2, thresholded2)&lt;br /&gt;
cvOr(thresholded, thresholded2, thresholded)&lt;/p&gt;
&lt;p&gt;</pre><p><strong><a href="../wp-content/uploads/2010/09/FastObjectTracking-process-Color-Filtering.jpg"><br /> </a></strong></p><h3><strong>Shape based tracking</strong></h3><p>Then, I used <a href="http://en.wikipedia.org/wiki/Hough_transform" target="_blank">Hough transform</a> to detect the shape of a circle. Before applying the hough transform I smoothed the image because it seems to improve the results.</p><p style="text-align: center;"><a href="http://www.lirtex.com/wp-content/uploads/2010/09/FastObjectTracking-process-Original-and-detected-object.jpg" rel="lightbox[173]" title="Fast Object Tracking original stream with detected object overlay"><img class="size-medium wp-image-247 aligncenter" title="Fast Object Tracking original stream with detected object overlay" src="http://www.lirtex.com/wp-content/uploads/2010/09/FastObjectTracking-process-Original-and-detected-object-300x240.jpg" alt="" width="300" height="240" /></a></p><pre class="brush: python; title: ; notranslate">&lt;/p&gt;
&lt;p&gt;# pre-smoothing improves Hough detector&lt;br /&gt;
cvSmooth(thresholded, thresholded, CV_GAUSSIAN, 9, 9)&lt;br /&gt;
circles = cvHoughCircles(thresholded, storage, CV_HOUGH_GRADIENT, 2, thresholded.height/4, 100, 40, 20, 200)&lt;/p&gt;
&lt;p&gt;</pre><h2>The result</h2><p>The result is pretty impressive. The code functions very well and detects the ball under most circumstances (i.e. the ball is far from the camera, close to the camera, slow movement, fast movement, etc).</p><p>You can see the result in this video:</p><p style="text-align: center;"><p><a href="http://www.youtube.com/watch?v=CigGvt3DXIw">http://www.youtube.com/watch?v=CigGvt3DXIw</a></p></p><h3>Full python sources including servo movement</h3><pre class="brush: python; title: ; notranslate">&lt;br /&gt;
/*****************************************************************************************&lt;br /&gt;
*  Name    : Fast object tracking using the OpenCV library                               *&lt;br /&gt;
*  Author  : Lior Chen &amp;lt;chen.lior@gmail.com&amp;gt;                                             *&lt;br /&gt;
*  Notice  : Copyright (c) Jun 2010, Lior Chen, All Rights Reserved                      *&lt;br /&gt;
*          :                                                                             *&lt;br /&gt;
*  Site    : http://www.lirtex.com                                                       *&lt;br /&gt;
*  WebPage : http://www.lirtex.com/robotics/fast-object-tracking-robot-computer-vision   *&lt;br /&gt;
*          :                                                                             *&lt;br /&gt;
*  Version : 1.0                                                                         *&lt;br /&gt;
*  Notes   : By default this code will open the first connected camera.                  *&lt;br /&gt;
*          : In order to change to another camera, change                                *&lt;br /&gt;
*          : CvCapture* capture = cvCaptureFromCAM( 0 ); to 1,2,3, etc.                  *&lt;br /&gt;
*          : Also, the code is currently configured to tracking RED objects.             *&lt;br /&gt;
*          : This can be changed by changing the hsv_min and hsv_max vectors             *&lt;br /&gt;
*          :                                                                             *&lt;br /&gt;
*  License : This program is free software: you can redistribute it and/or modify        *&lt;br /&gt;
*          : it under the terms of the GNU General Public License as published by        *&lt;br /&gt;
*          : the Free Software Foundation, either version 3 of the License, or           *&lt;br /&gt;
*          : (at your option) any later version.                                         *&lt;br /&gt;
*          :                                                                             *&lt;br /&gt;
*          : This program is distributed in the hope that it will be useful,             *&lt;br /&gt;
*          : but WITHOUT ANY WARRANTY; without even the implied warranty of              *&lt;br /&gt;
*          : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *&lt;br /&gt;
*          : GNU General Public License for more details.                                *&lt;br /&gt;
*          :                                                                             *&lt;br /&gt;
*          : You should have received a copy of the GNU General Public License           *&lt;br /&gt;
*          : along with this program.  If not, see &amp;lt;http://www.gnu.org/licenses/&amp;gt;        *&lt;br /&gt;
******************************************************************************************/&lt;br /&gt;
#!/usr/bin/python&lt;br /&gt;
# -*- coding: utf-8 -*-&lt;/p&gt;
&lt;p&gt;from opencv.cv import *&lt;br /&gt;
from opencv.highgui import *&lt;br /&gt;
from threading import Thread&lt;br /&gt;
#import serial&lt;/p&gt;
&lt;p&gt;class RobotVision:&lt;br /&gt;
	cvSize size&lt;br /&gt;
	cvImage hsv_frame, thresholded, thresholded2&lt;br /&gt;
	cvScalar hsv_min, hsv_max, hsv_min2, hsv_max2&lt;br /&gt;
	cvCapture capture;&lt;/p&gt;
&lt;p&gt;	def InitBallTracking():&lt;br /&gt;
		globals size,  hsv_frame, thresholded, thresholded2, hsv_min, hsv_max, hsv_min2, hsv_max2, capture&lt;br /&gt;
		print &amp;quot;Initializing ball Tracking&amp;quot;&lt;br /&gt;
		size = cvSize(640, 480)&lt;br /&gt;
		hsv_frame = cvCreateImage(size, IPL_DEPTH_8U, 3)&lt;br /&gt;
		thresholded = cvCreateImage(size, IPL_DEPTH_8U, 1)&lt;br /&gt;
		thresholded2 = cvCreateImage(size, IPL_DEPTH_8U, 1)&lt;/p&gt;
&lt;p&gt;		hsv_min = cvScalar(0, 50, 170, 0)&lt;br /&gt;
		hsv_max = cvScalar(10, 180, 256, 0)&lt;br /&gt;
		hsv_min2 = cvScalar(170, 50, 170, 0)&lt;br /&gt;
		hsv_max2 = cvScalar(256, 180, 256, 0)&lt;/p&gt;
&lt;p&gt;		storage = cvCreateMemStorage(0)&lt;/p&gt;
&lt;p&gt;		# start capturing form webcam&lt;br /&gt;
		capture = cvCreateCameraCapture(-1)&lt;/p&gt;
&lt;p&gt;		if not capture:&lt;br /&gt;
			print &amp;quot;Could not open webcam&amp;quot;&lt;br /&gt;
			sys.exit(1)&lt;/p&gt;
&lt;p&gt;		#CV windows&lt;br /&gt;
		cvNamedWindow( &amp;quot;Camera&amp;quot;, CV_WINDOW_AUTOSIZE );&lt;/p&gt;
&lt;p&gt;	def TrackBall(i):&lt;br /&gt;
		t = Thread(target=TrackBallThread, args=(i,))&lt;br /&gt;
		t.start()&lt;/p&gt;
&lt;p&gt;	def TrackBallThread(num_of_balls):&lt;br /&gt;
		globals size,  hsv_frame, thresholded, thresholded2, hsv_min, hsv_max, hsv_min2, hsv_max2, capture&lt;br /&gt;
		while 1:&lt;br /&gt;
			# get a frame from the webcam&lt;br /&gt;
			frame = cvQueryFrame(capture)&lt;/p&gt;
&lt;p&gt;			if frame is not None:&lt;/p&gt;
&lt;p&gt;				# convert to HSV for color matching&lt;br /&gt;
				# as hue wraps around, we need to match it in 2 parts and OR together&lt;br /&gt;
				cvCvtColor(frame, hsv_frame, CV_BGR2HSV)&lt;br /&gt;
				cvInRangeS(hsv_frame, hsv_min, hsv_max, thresholded)&lt;br /&gt;
				cvInRangeS(hsv_frame, hsv_min2, hsv_max2, thresholded2)&lt;br /&gt;
				cvOr(thresholded, thresholded2, thresholded)&lt;/p&gt;
&lt;p&gt;				# pre-smoothing improves Hough detector&lt;br /&gt;
				cvSmooth(thresholded, thresholded, CV_GAUSSIAN, 9, 9)&lt;br /&gt;
				circles = cvHoughCircles(thresholded, storage, CV_HOUGH_GRADIENT, 2, thresholded.height/4, 100, 40, 20, 200)&lt;/p&gt;
&lt;p&gt;				# find largest circle&lt;br /&gt;
				maxRadius = 0&lt;br /&gt;
				x = 0&lt;br /&gt;
				y = 0&lt;br /&gt;
				found = False&lt;br /&gt;
				for i in range(circles.total):&lt;br /&gt;
					circle = circles[i]&lt;br /&gt;
					if circle[2] &amp;gt; maxRadius:&lt;br /&gt;
						found = True&lt;br /&gt;
						maxRadius = circle[2]&lt;br /&gt;
						x = circle[0]&lt;br /&gt;
						y = circle[1]&lt;/p&gt;
&lt;p&gt;				cvShowImage( &amp;quot;Camera&amp;quot;, frame );&lt;/p&gt;
&lt;p&gt;				if found:&lt;br /&gt;
					print &amp;quot;ball detected at position:&amp;quot;,x, &amp;quot;,&amp;quot;, y, &amp;quot; with radius:&amp;quot;, maxRadius&lt;/p&gt;
&lt;p&gt;					if x &amp;gt; 420:&lt;br /&gt;
						# need to pan right&lt;br /&gt;
						servoPos += 5&lt;br /&gt;
						servoPos = min(140, servoPos)&lt;br /&gt;
						servo(2, servoPos)&lt;br /&gt;
					elif x &amp;lt; 220:&lt;br /&gt;
						servoPos -= 5&lt;br /&gt;
						servoPos = max(40, servoPos)&lt;br /&gt;
						servo(2, servoPos)&lt;br /&gt;
					print &amp;quot;servo position:&amp;quot;, servoPos&lt;br /&gt;
				else:&lt;br /&gt;
					print &amp;quot;no ball&amp;quot;&lt;br /&gt;
</pre><h2>Sample Sources</h2><p>This c++ code takes a video stream from an attached video camera, looks for an orange ball inside the stream, and prints the coordinates of the ball.<br /> Three &#8220;debug&#8221; windows are shown to clarify the process: 1) the video capture. 2) the stream after the conversion to HSV, 3) the stream after conversion to HSV, color-filtering, and Hough transform.</p><pre class="brush: cpp; title: ; notranslate">&lt;br /&gt;
/*****************************************************************************************&lt;br /&gt;
*  Name    : Fast object tracking using the OpenCV library                               *&lt;br /&gt;
*  Author  : Lior Chen &amp;lt;chen.lior@gmail.com&amp;gt;                                             *&lt;br /&gt;
*  Notice  : Copyright (c) Jun 2010, Lior Chen, All Rights Reserved                      *&lt;br /&gt;
*          :                                                                             *&lt;br /&gt;
*  Site    : http://www.lirtex.com                                                       *&lt;br /&gt;
*  WebPage : http://www.lirtex.com/robotics/fast-object-tracking-robot-computer-vision   *&lt;br /&gt;
*          :                                                                             *&lt;br /&gt;
*  Version : 1.0                                                                         *&lt;br /&gt;
*  Notes   : By default this code will open the first connected camera.                  *&lt;br /&gt;
*          : In order to change to another camera, change                                *&lt;br /&gt;
*          : CvCapture* capture = cvCaptureFromCAM( 0 ); to 1,2,3, etc.                  *&lt;br /&gt;
*          : Also, the code is currently configured to tracking RED objects.             *&lt;br /&gt;
*          : This can be changed by changing the hsv_min and hsv_max vectors             *&lt;br /&gt;
*          :                                                                             *&lt;br /&gt;
*  License : This program is free software: you can redistribute it and/or modify        *&lt;br /&gt;
*          : it under the terms of the GNU General Public License as published by        *&lt;br /&gt;
*          : the Free Software Foundation, either version 3 of the License, or           *&lt;br /&gt;
*          : (at your option) any later version.                                         *&lt;br /&gt;
*          :                                                                             *&lt;br /&gt;
*          : This program is distributed in the hope that it will be useful,             *&lt;br /&gt;
*          : but WITHOUT ANY WARRANTY; without even the implied warranty of              *&lt;br /&gt;
*          : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *&lt;br /&gt;
*          : GNU General Public License for more details.                                *&lt;br /&gt;
*          :                                                                             *&lt;br /&gt;
*          : You should have received a copy of the GNU General Public License           *&lt;br /&gt;
*          : along with this program.  If not, see &amp;lt;http://www.gnu.org/licenses/&amp;gt;        *&lt;br /&gt;
******************************************************************************************/&lt;/p&gt;
&lt;p&gt;#include &amp;lt;opencv/cvaux.h&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv/highgui.h&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv/cxcore.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;/p&gt;
&lt;p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;assert.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;float.h&amp;gt;&lt;br /&gt;
#include &amp;lt;limits.h&amp;gt;&lt;br /&gt;
#include &amp;lt;time.h&amp;gt;&lt;br /&gt;
#include &amp;lt;ctype.h&amp;gt;&lt;/p&gt;
&lt;p&gt;int main(int argc, char* argv[])&lt;br /&gt;
{&lt;/p&gt;
&lt;p&gt;    // Default capture size - 640x480&lt;br /&gt;
    CvSize size = cvSize(640,480);&lt;/p&gt;
&lt;p&gt;    // Open capture device. 0 is /dev/video0, 1 is /dev/video1, etc.&lt;br /&gt;
    CvCapture* capture = cvCaptureFromCAM( 0 );&lt;br /&gt;
    if( !capture )&lt;br /&gt;
    {&lt;br /&gt;
            fprintf( stderr, &amp;quot;ERROR: capture is NULL \n&amp;quot; );&lt;br /&gt;
            getchar();&lt;br /&gt;
            return -1;&lt;br /&gt;
    }&lt;/p&gt;
&lt;p&gt;    // Create a window in which the captured images will be presented&lt;br /&gt;
    cvNamedWindow( &amp;quot;Camera&amp;quot;, CV_WINDOW_AUTOSIZE );&lt;br /&gt;
    cvNamedWindow( &amp;quot;HSV&amp;quot;, CV_WINDOW_AUTOSIZE );&lt;br /&gt;
    cvNamedWindow( &amp;quot;EdgeDetection&amp;quot;, CV_WINDOW_AUTOSIZE );&lt;/p&gt;
&lt;p&gt;    // Detect a red ball&lt;br /&gt;
    CvScalar hsv_min = cvScalar(150, 84, 130, 0);&lt;br /&gt;
    CvScalar hsv_max = cvScalar(358, 256, 255, 0);&lt;/p&gt;
&lt;p&gt;    IplImage *  hsv_frame    = cvCreateImage(size, IPL_DEPTH_8U, 3);&lt;br /&gt;
    IplImage*  thresholded   = cvCreateImage(size, IPL_DEPTH_8U, 1);&lt;/p&gt;
&lt;p&gt;    while( 1 )&lt;br /&gt;
    {&lt;br /&gt;
        // Get one frame&lt;br /&gt;
        IplImage* frame = cvQueryFrame( capture );&lt;br /&gt;
        if( !frame )&lt;br /&gt;
        {&lt;br /&gt;
                fprintf( stderr, &amp;quot;ERROR: frame is null...\n&amp;quot; );&lt;br /&gt;
                getchar();&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;/p&gt;
&lt;p&gt;        // Covert color space to HSV as it is much easier to filter colors in the HSV color-space.&lt;br /&gt;
        cvCvtColor(frame, hsv_frame, CV_BGR2HSV);&lt;br /&gt;
        // Filter out colors which are out of range.&lt;br /&gt;
        cvInRangeS(hsv_frame, hsv_min, hsv_max, thresholded);&lt;/p&gt;
&lt;p&gt;        // Memory for hough circles&lt;br /&gt;
        CvMemStorage* storage = cvCreateMemStorage(0);&lt;br /&gt;
        // hough detector works better with some smoothing of the image&lt;br /&gt;
        cvSmooth( thresholded, thresholded, CV_GAUSSIAN, 9, 9 );&lt;br /&gt;
        CvSeq* circles = cvHoughCircles(thresholded, storage, CV_HOUGH_GRADIENT, 2,&lt;br /&gt;
                                        thresholded-&amp;gt;height/4, 100, 50, 10, 400);&lt;/p&gt;
&lt;p&gt;        for (int i = 0; i &amp;lt; circles-&amp;gt;total; i++)&lt;br /&gt;
        {&lt;br /&gt;
            float* p = (float*)cvGetSeqElem( circles, i );&lt;br /&gt;
            printf(&amp;quot;Ball! x=%f y=%f r=%f\n\r&amp;quot;,p[0],p[1],p[2] );&lt;br /&gt;
            cvCircle( frame, cvPoint(cvRound(p[0]),cvRound(p[1])),&lt;br /&gt;
                                    3, CV_RGB(0,255,0), -1, 8, 0 );&lt;br /&gt;
            cvCircle( frame, cvPoint(cvRound(p[0]),cvRound(p[1])),&lt;br /&gt;
                                    cvRound(p[2]), CV_RGB(255,0,0), 3, 8, 0 );&lt;br /&gt;
        }&lt;/p&gt;
&lt;p&gt;        cvShowImage( &amp;quot;Camera&amp;quot;, frame ); // Original stream with detected ball overlay&lt;br /&gt;
        cvShowImage( &amp;quot;HSV&amp;quot;, hsv_frame); // Original stream in the HSV color space&lt;br /&gt;
        cvShowImage( &amp;quot;After Color Filtering&amp;quot;, thresholded ); // The stream after color filtering&lt;/p&gt;
&lt;p&gt;        cvReleaseMemStorage(&amp;amp;storage);&lt;/p&gt;
&lt;p&gt;        // Do not release the frame!&lt;/p&gt;
&lt;p&gt;        //If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),&lt;br /&gt;
        //remove higher bits using AND operator&lt;br /&gt;
        if( (cvWaitKey(10) &amp;amp; 255) == 27 ) break;&lt;br /&gt;
    }&lt;/p&gt;
&lt;p&gt;     // Release the capture device housekeeping&lt;br /&gt;
     cvReleaseCapture( &amp;amp;capture );&lt;br /&gt;
     cvDestroyWindow( &amp;quot;mywindow&amp;quot; );&lt;br /&gt;
     return 0;&lt;br /&gt;
   }&lt;br /&gt;
</pre>]]></content:encoded> <wfw:commentRss>http://www.lirtex.com/robotics/fast-object-tracking-robot-computer-vision/feed/</wfw:commentRss> <slash:comments>51</slash:comments> </item> <item><title>Linux Robotic Platform &#8211; an Intelligent Robot</title><link>http://www.lirtex.com/robotics/linux-robotic-platform-an-intelligent-robot/</link> <comments>http://www.lirtex.com/robotics/linux-robotic-platform-an-intelligent-robot/#comments</comments> <pubDate>Mon, 05 Jul 2010 10:18:19 +0000</pubDate> <dc:creator>Lior Chen</dc:creator> <category><![CDATA[Robotics]]></category> <category><![CDATA[Computer Vision]]></category> <category><![CDATA[DC Motor]]></category> <category><![CDATA[Electronic Circuit]]></category> <category><![CDATA[Embedded]]></category> <category><![CDATA[Image Processing]]></category> <category><![CDATA[Motor Control]]></category> <category><![CDATA[Robot]]></category> <category><![CDATA[Sensor]]></category> <category><![CDATA[Servo Motor]]></category> <category><![CDATA[Speech Recognition]]></category> <category><![CDATA[USB]]></category><guid isPermaLink="false">http://www.lirtex.com/wp/?p=59</guid> <description><![CDATA[I have always wanted to experiment with robotics, and lately I&#8217;ve found the time to build an &#8220;intelligent&#8221;, open-source robotic platform. The platform runs embedded debian linux, and includes the following main capabilities: 1. Computer Vision (imitation of the human vision. The robot sees and &#8220;understands&#8221; what it sees). For this I have extensively used [...]]]></description> <content:encoded><![CDATA[<p><a href="http://www.lirtex.com/wp-content/uploads/2010/07/FrontCamera.jpg" rel="lightbox[59]" title="Intellibot - an Intelligent Robot"><img class="alignright size-full wp-image-391" title="Intellibot - an Intelligent Robot" src="http://www.lirtex.com/wp-content/uploads/2010/07/FrontCamera.jpg" alt="Intellibot - an Intelligent Robot" width="272" height="297" /></a></p><p>I have always wanted to experiment with robotics, and lately I&#8217;ve found the time to build an &#8220;intelligent&#8221;, open-source robotic platform.</p><p>The platform runs embedded debian linux, and includes the following main capabilities:</p><p>1. Computer Vision (imitation of the human vision. The robot sees and &#8220;understands&#8221; what it sees). For this I have extensively used the OpenCV project.</p><p>2. Speech Synthesis (imitation of human speech. The ability to speak). For this I have used Espeak.</p><p>3. Speech Recognition (the ability to understand vocal commands). For this I have used CMU Sphinx 4 (after modifying some of the files in the project)</p><p><span id="more-59"></span></p><p style="text-align: center;">Just a teaser, before I upload more videos:</p><p><a href="http://www.youtube.com/watch?v=okt-2_VxGfc&#038;fmt=18">http://www.youtube.com/watch?v=okt-2_VxGfc</a></p><p>List of Computer Vision capabilities:</p><p style="text-align: justify;">1. Line Following</p><p>2. Object Tracking</p><p>3. Facial Recognition (uses face API from face.com)</p><p>List of Speech Synthesis Capabilities:</p><p>1. Speaking the current action (&#8220;Moving Forward&#8221; etc)</p><p>2. Saying &#8220;Hi &lt;name&gt;&#8221; when it recognizes a face</p><p>Current list of Speech Recognition Capabilities:</p><p>1. Full movement control (&#8220;Move Forward\Backward&#8221;, &#8220;Turn Left\Right&#8221;, &#8220;Stop&#8221;)</p><p>2. Initialization of algorithms: &#8220;Follow Line\RedBall&#8221;, &#8220;Find Face&#8221;</p><h1 style="text-align: justify;">Robot Diagram</h1><p style="text-align: center;"><a href="http://www.lirtex.com/wp-content/uploads/2010/07/Intellibot-TLD-1024x768.jpg" rel="lightbox[59]" title="Robotic Platform Top Level Diagram"><img class="size-full wp-image-280 aligncenter" title="Robotic Platform Top Level Diagram" src="http://www.lirtex.com/wp-content/uploads/2010/07/Intellibot-TLD-1024x768.jpg" alt="" width="740" height="555" /></a></p><p style="text-align: center;"><p style="text-align: center;"><p style="text-align: center;"><p style="text-align: center;"><p style="text-align: center;"><p>&nbsp;</p> ]]></content:encoded> <wfw:commentRss>http://www.lirtex.com/robotics/linux-robotic-platform-an-intelligent-robot/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Automatic Caller Identifier for Maemo (Nokia Linux OS)</title><link>http://www.lirtex.com/embedded/automatic-caller-identifier-for-maemo-nokia-linux-os/</link> <comments>http://www.lirtex.com/embedded/automatic-caller-identifier-for-maemo-nokia-linux-os/#comments</comments> <pubDate>Tue, 01 Jun 2010 20:43:43 +0000</pubDate> <dc:creator>Lior Chen</dc:creator> <category><![CDATA[Embedded]]></category> <category><![CDATA[Embedded Linux]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Wifi]]></category><guid isPermaLink="false">http://www.lirtex.com/?p=284</guid> <description><![CDATA[Automatic Caller Identification uses several sites on the internet to find the identification of unknown incoming calls, and display it while receiving such calls. The project is developed for Maemo, Nokia&#8217;s embedded Linux operating system. For years I have waited for having my own phone that would run Linux. A phone I will be able [...]]]></description> <content:encoded><![CDATA[<p><a href="http://www.lirtex.com/wp-content/uploads/2010/06/n900.png" rel="lightbox[284]" title="Nokia N900"><img class="alignright size-full wp-image-441" style="border-style: initial; border-color: initial; border-image: initial; border-width: 0px;" title="Nokia N900" src="http://www.lirtex.com/wp-content/uploads/2010/06/n900.png" alt="Nokia N900" width="320" height="290" /></a></p><p>Automatic Caller Identification uses several sites on the internet to find the identification of unknown incoming calls, and display it while receiving such calls.</p><p>The project is developed for <a href="http://maemo.org/" target="_blank">Maemo</a>, Nokia&#8217;s embedded Linux operating system.</p><p><span id="more-284"></span></p><p style="text-align: left;">For years I have waited for having my own phone that would run Linux. A phone I will be able to use just like any other system, stacked with a full programming tool-chain, ssh access, a decent packaging system, and my favorite set of application. Finally, that day has come.<a href="http://maemo.nokia.com/n900/" target="_blank"> Nokia N900</a> is a fully based Linux based phone which runs Maemo &#8211; an SDK and a software platform which is based on my long loved <a title="Debian" href="http://en.wikipedia.org/wiki/Debian">Debian</a> <a title="Linux distribution" href="http://en.wikipedia.org/wiki/Linux_distribution">Linux distribution</a>.</p><p style="text-align: left;">This post will describe the process of developing an Maemo application for the Nokia N900. I will use my <strong>Automatic Caller Identification</strong> program as an example.</p><h2 style="text-align: left;"><a href="http://www.lirtex.com/wp-content/uploads/2010/09/Automatic-Caller-Identification-Maemo.jpg" rel="lightbox[284]" title="Automatic Caller Identification Maemo"><img class="alignright size-medium wp-image-285" title="Automatic Caller Identification Maemo" src="http://www.lirtex.com/wp-content/uploads/2010/09/Automatic-Caller-Identification-Maemo-640x335.jpg" alt="" width="320" height="167" /></a>Automatic Caller Identification?</h2><p>Simply put, an automatic caller identification system is a system that can identify unknown numbers (i.e. phone numbers which are not currently stored in your phone book). Since the N900 has a built in internet connection (either Wifi or 3G), I wanted to create a program that once an unidentified call is received, will use several sites in the internet to identify the caller and display its details. Since I live in Israel I first experienced with Israeli numbers, but the code is modular enough to extend it to other countries \ internet databases as well. The database I used was <a href="http://441il.com/" target="_blank">http://441il.com/</a>.</p><h2>The development Process</h2><h3>Development Environment</h3><h3>Maemo SDK</h3><h2 style="text-align: left;">Live example</h2><p><a href="http://www.youtube.com/watch?v=viuhEDIjAIA&#038;fmt=18">http://www.youtube.com/watch?v=viuhEDIjAIA</a></p><h2>Links and Source-code</h2><p><a href="https://garage.maemo.org/projects/caller-id/">https://garage.maemo.org/projects/caller-id/</a></p> ]]></content:encoded> <wfw:commentRss>http://www.lirtex.com/embedded/automatic-caller-identifier-for-maemo-nokia-linux-os/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Building a Custom Debian Kernel for the BeagleBoard</title><link>http://www.lirtex.com/embedded/building-a-custom-debian-kernel-for-the-beagleboard/</link> <comments>http://www.lirtex.com/embedded/building-a-custom-debian-kernel-for-the-beagleboard/#comments</comments> <pubDate>Sun, 24 May 2009 11:49:26 +0000</pubDate> <dc:creator>Lior Chen</dc:creator> <category><![CDATA[Embedded]]></category> <category><![CDATA[Beagleboard]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Embedded Linux]]></category> <category><![CDATA[Kernel]]></category><guid isPermaLink="false">http://www.lirtex.com/wp/?p=96</guid> <description><![CDATA[While trying to get my WIFI dongle to work with the BeagleBoard, I noticed that the dongle&#8217;s module was not compiled into the kernel. So I had to build a new kernel from scratch. Since building a new kernel under the BeagleBoard will take a LOT of time, I decided to cross-compile a kernel for [...]]]></description> <content:encoded><![CDATA[<p><a href="http://www.lirtex.com/wp-content/uploads/2009/05/kernel-273x300.png" rel="lightbox[96]" title="Linux Kernel"><img class="alignright size-full wp-image-305" style="border: 0pt none;" title="Linux Kernel" src="http://www.lirtex.com/wp-content/uploads/2009/05/kernel-273x300.png" alt="" width="273" height="300" /></a>While trying to get my WIFI dongle to work with the BeagleBoard, I noticed that the dongle&#8217;s module was not compiled into the kernel. So I had to build a new kernel from scratch. Since building a new kernel under the BeagleBoard will take a <strong>LOT</strong> of time, I decided to cross-compile a kernel for the ARM architecture under my AMD-64 arch PC.</p><p>The following steps describes building a custom Debian kernel for the BeagleBoard using cross-compiling:</p><p><span id="more-96"></span></p><h3>Installing required dependencies</h3><p>Install proper build environment:</p><blockquote><pre>apt-get install git-core kernel-package fakeroot build-essential \
curl libncurses-dev uboot-mkimage</pre></blockquote><p>Edit /etc/apt/sources.list and add the Embedded Debian Project sources:</p><blockquote><p>#debian embedded<br /> deb http://www.emdebian.org/debian/ unstable main</p></blockquote><p>Now execute:</p><blockquote><p>apt-get update<br /> apt-get install cpp-4.3-arm-linux-gnu  g++-4.3-arm-linux-gnu gcc-4.3-arm-linux-gnu</p></blockquote><p>You now have a build environment capable of compiling a kernel for the ARM platform. Next step is to acquire and compile the kernel</p><h3>Acquiring and Compiling the Kernel</h3><p>Retrieve the GIT checkout:</p><blockquote><pre>git clone git://git2.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git
cd linux-omap-2.6/
git checkout 58cf2f1 -b v2.6.29-58cf2f1
git archive --format=tar --prefix=v2.6.29-58cf2f1/ v2.6.29-58cf2f1 | gzip &gt; ../v2.6.29-58cf2f1.tar.gz
git checkout master
git branch v2.6.29-58cf2f1 -D
cd ..</pre></blockquote><p>Download kernel diffs and kernel config:</p><blockquote><pre>wget <a title="http://rcn-ee.homeip.net:81/dl/omap/beagle/v2.6.29-58cf2f1-oer34/v2.6.29-58cf2f1-oer34.diff" rel="nofollow" href="http://rcn-ee.homeip.net:81/dl/omap/beagle/v2.6.29-58cf2f1-oer34/v2.6.29-58cf2f1-oer34.diff">http://rcn-ee.homeip.net:81/dl/omap/beagle/v2.6.29-58cf2f1-oer34/v2.6.29-58cf2f1-oer34.diff</a>
wget <a title="http://rcn-ee.homeip.net:81/dl/omap/beagle/v2.6.29-58cf2f1-oer34/defconfig" rel="nofollow" href="http://rcn-ee.homeip.net:81/dl/omap/beagle/v2.6.29-58cf2f1-oer34/defconfig">http://rcn-ee.homeip.net:81/dl/omap/beagle/v2.6.29-58cf2f1-oer34/defconfig</a></pre></blockquote><p>Extract Kernel Source</p><blockquote><pre>tar -xf v2.6.29-58cf2f1.tar.gz
cd v2.6.29-58cf2f1/</pre></blockquote><p>Apply Patch</p><blockquote><pre>patch -p1 &lt; ../v2.6.29-58cf2f1-oer34.diff</pre></blockquote><p>Copy Defconfig</p><blockquote><pre>cp ../defconfig .config</pre></blockquote><p>Configure the kernel (requires libncurses5-dev installed)</p><blockquote><pre>make menuconfig</pre></blockquote><p>Build, Cross-Compiling:</p><blockquote><p>make CROSS_COMPILE=arm-linux-gnu- uImage</p></blockquote><p>A few moments later, you can find your new kernel in the &#8216;arch/arm/boot/&#8217; directory.</p><p>Make modules:</p><blockquote><p>make CROSS_COMPILE=arm-linux-gnu- modules</p><p>make CROSS_COMPILE=arm-linux-gnu- modules_install</p><p>make CROSS_COMPILE=arm-linux-gnu- modules_install INSTALL_MOD_PATH=arch/arm/boot”</p></blockquote><p>Congratulations, a new kernel is compiled! Now move uImage and the arch/arm/boot directory to the sdcard.</p><p>Next step is to boot and test my WIFI dongle again.</p><p>You can find some more information about building a Debian kernel <a href="http://elinux.org/BeagleBoardDebian">here</a>.</p> ]]></content:encoded> <wfw:commentRss>http://www.lirtex.com/embedded/building-a-custom-debian-kernel-for-the-beagleboard/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 17/32 queries in 0.119 seconds using disk: basic
Object Caching 575/672 objects using disk: basic

Served from: www.lirtex.com @ 2012-05-18 18:18:55 -->
