Go to Post Don't date anyone on your team unless you are POSITVE that you will be able to handle yourself professionally, not only during your relationship, but even after it ends. - Jaine Perotti [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-01-2014, 15:15
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Best Way to Learn Vision Processing

So many of you may know how I've been trying vision processing. I finally got a working install of OpenCV in Windows, using VS C++ Express 2010. However, I don't know where to start when learning OpenCV. What tutorials do you suggest? Are there any books I could look out for when I go to the public library? Video tutorials should work too.

Other than that, what webcam should I persuade either my parents or my team to buy? I don't think my laptop's integrated camera will cut it

Thanks
  #2   Spotlight this post!  
Unread 02-01-2014, 22:07
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Best Way to Learn Vision Processing

The OpenCV documentation is actually rather good, and I found the example code to be pretty informative when I was learning OpenCV. I learn best by example, though, so YMMV. If you want a more edited, traditional book, there are a bunch listed here; you're probably most likely to find the O'Reilly OpenCV book (the first one listed, with the butterfly).

Once you've gone through a few examples, I'd suggest trying to solve one of the past years' challenges (or you can wait until Saturday ). OpenCV is a large enough library that you'll get lost if you try to learn the entire thing without some sort of specific challenge to direct your efforts.

If you have access to the game elements from those years, that would obviously be the best; else I'd suggest looking for pictures on Chief Delphi (ex: Jared from 341 posted some example camera captures from the 2012 game) or on-robot camera footage off of YouTube (keepvid.com/). Just try applying some of the filters and see what happens. I'd recommend starting with smoothing operators, color-space conversions, and thresholds. From there, you can move onto contour analysis and simple shape detection using Hough transforms.

When it comes to webcams, some are slightly better than others, but in my experience they're all about the same. The real advantage to having another webcam besides the one built into your laptop is that you can easily aim it at things without having to contort yourself and your laptop into weird poses.
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor

Last edited by RyanCahoon : 02-01-2014 at 22:10.
  #3   Spotlight this post!  
Unread 02-01-2014, 22:34
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,082
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Best Way to Learn Vision Processing

C++ OpenCV 2.0 may or may not be the best way to get into vision processing depending on your software background. Because it is a big library that does a lot of complicated things, there is a pretty steep learning curve. Moreover, current versions of OpenCV rely upon a pretty solid foundation in modern C++.

If you know Python, I recommend using OpenCV's Python bindings for rapid prototyping: it is syntactically simplified and quicker to throw together something that works in my experience.

If you have access to it, I highly recommend using Matlab's Image Processing Toolbox. I learned a large part of my foundation in vision from using its functions and (just as importantly) reading its documentation.

Computer vision is such an interesting subject because it combines so many disciplines of mathematics and computer science. I first took several courses in signal processing before diving into vision, and was glad I did so; many vision problems can be described as filtering problems. Graph theory, 3D geometry, and machine learning are all also very relevant fields. I would start with whichever one of these you might have some background, and grow from there.

Classic algorithms or techniques to get familiar with:

The pinhole camera model
Camera calibration
Thresholding
Binary morphology (erode/dilate)
Edge/corner detection
Correlation/Cross-correlation

I think that is pretty close to the order I would go in, as well (maybe gloss over calibration quickly at first).
  #4   Spotlight this post!  
Unread 03-01-2014, 20:01
Patrick Shainin Patrick Shainin is offline
Registered User
FRC #3238
Team Role: Mentor
 
Join Date: Dec 2013
Rookie Year: 2009
Location: Anacortes, Washington, USA
Posts: 5
Patrick Shainin is an unknown quantity at this point
Re: Best Way to Learn Vision Processing

Here's a Python 'tutorial' I put together to help our team better understand the algorithm described in the FIRST vision processing doc @ http://wpilib.screenstepslive.com/s/3120/m/8731, and the similar team 341 posted vision code.

Maybe you will find it helpful if you aren't past this point yet.

https://github.com/LiftingSea/frc_vision_tutorial

It also leveraged some of the OpenCV tutorials to open multiple windows for the various stages of the processing, and provide some knobs for experimenting with tuning the algorithm in real time.

I started writing it in C++ using just the open source gcc compiler, and, as mentioned in another post here, decided to take advantage of the interactive and friendlier Python environment.

The 'tutorial' involves running the program and seeing how the tuning knobs affect the targeting results, as well as some suggested 'next steps' for students to take in the comments at the beginning of the file, to facilitate learning by example.
  #5   Spotlight this post!  
Unread 03-01-2014, 20:32
Jerry Ballard's Avatar
Jerry Ballard Jerry Ballard is offline
Registered User
AKA: Jerry Ballard
FRC #0456 (Siege Robotics)
Team Role: Mentor
 
Join Date: Dec 2012
Rookie Year: 2011
Location: Vicksburg, MS, USA
Posts: 13
Jerry Ballard is a jewel in the roughJerry Ballard is a jewel in the roughJerry Ballard is a jewel in the rough
Re: Best Way to Learn Vision Processing

Quote:
Originally Posted by yash101 View Post
Other than that, what webcam should I persuade either my parents or my team to buy? I don't think my laptop's integrated camera will cut it
Thanks
Last year we were sucessful using cheap Logitech webcams (C110 or C210) that you can find at a bigbox store for about $20. Since they are cheap and have been available for a long time, the Linux device drivers for these are fairly robust.
  #6   Spotlight this post!  
Unread 03-01-2014, 22:58
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Best Way to Learn Vision Processing

Quote:
Originally Posted by Jerry Ballard View Post
Last year we were sucessful using cheap Logitech webcams (C110 or C210) that you can find at a bigbox store for about $20. Since they are cheap and have been available for a long time, the Linux device drivers for these are fairly robust.
That is one reason why I am looking at Logitech. They are dirt cheap and work, a value for their price.

Quote:
Originally Posted by Patrick Shainin View Post
Here's a Python 'tutorial' I put together to help our team better understand the algorithm described in the FIRST vision processing doc @ http://wpilib.screenstepslive.com/s/3120/m/8731, and the similar team 341 posted vision code.

Maybe you will find it helpful if you aren't past this point yet.

https://github.com/LiftingSea/frc_vision_tutorial

It also leveraged some of the OpenCV tutorials to open multiple windows for the various stages of the processing, and provide some knobs for experimenting with tuning the algorithm in real time.

I started writing it in C++ using just the open source gcc compiler, and, as mentioned in another post here, decided to take advantage of the interactive and friendlier Python environment.

The 'tutorial' involves running the program and seeing how the tuning knobs affect the targeting results, as well as some suggested 'next steps' for students to take in the comments at the beginning of the file, to facilitate learning by example.
I have a working Windows install with C++. I also have a working Python install with Ubuntu/Linux. I don't know if that link works. It takes me to the index page of the Screenstepslive.

Quote:
Originally Posted by RyanCahoon View Post
The OpenCV documentation is actually rather good, and I found the example code to be pretty informative when I was learning OpenCV. I learn best by example, though, so YMMV. If you want a more edited, traditional book, there are a bunch listed here; you're probably most likely to find the O'Reilly OpenCV book (the first one listed, with the butterfly).

Once you've gone through a few examples, I'd suggest trying to solve one of the past years' challenges (or you can wait until Saturday ). OpenCV is a large enough library that you'll get lost if you try to learn the entire thing without some sort of specific challenge to direct your efforts.

If you have access to the game elements from those years, that would obviously be the best; else I'd suggest looking for pictures on Chief Delphi (ex: Jared from 341 posted some example camera captures from the 2012 game) or on-robot camera footage off of YouTube (keepvid.com/). Just try applying some of the filters and see what happens. I'd recommend starting with smoothing operators, color-space conversions, and thresholds. From there, you can move onto contour analysis and simple shape detection using Hough transforms.

When it comes to webcams, some are slightly better than others, but in my experience they're all about the same. The real advantage to having another webcam besides the one built into your laptop is that you can easily aim it at things without having to contort yourself and your laptop into weird poses.
I like the OpenCV documentation because it is detailed, easy to follow and is through/complete. However, it is so detailed that I have no clue where to start. I have been chatting with John (antimatter_john) and via VNC, I showed him how I got OpenCV installed and how to install python-opencv in Ubuntu (within vBox).

It also comes down to that me (an many other novices) don't know what to learn and what to skip. So far, the only thing I've been able to accomplish is finding a certain color (which didn't work too well because I didn't have a colored object to track). I looked in our library's online catalog and can say that our library is missing basic AI books. The only thing I could find were books on how to hack and use the Kinect, not exactly what I am looking for .

I will probably dissect the 341 code and rewrite it in C.

Anyways, so I have an OpenCV C++ installation. How do I install the Java bindings? With 5GB of HDD storage available, I don't want to install a compiler to build it. Also, how well is it documented? Is it as good as the C++ version of OpenCV?

Another thing I wonder about is whether to learn C, C++, Java or Python or maybe even something else.

One thing that I dislike about C is that the program will compile correctly. However, when I launch it, it will spit out just tons of fatal errors. How can I set the IDE (Visual Studio currently) to tell me that there are errors in the code? I have actually had my system hang because of a simple typo!
  #7   Spotlight this post!  
Unread 04-01-2014, 00:47
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Best Way to Learn Vision Processing

Quote:
Originally Posted by yash101 View Post
However, it is so detailed that I have no clue where to start. [...] It also comes down to that me (an many other novices) don't know what to learn and what to skip.
[...]
I will probably dissect the 341 code and rewrite it in C.
IMO, there are basically two ways to go about learning something. 1) you can pick a corner to start nibbling at and random-walk your way outward until you cobble together enough to solve the problem you're currently working on 2) you can go about trying to learn the big picture and theory of the entire subject, and then try to figure out how that applies to your current problem.

Jared and I gave you lists of topics to get started with also as a way to try to give you some direction about where to focus initially.

If you like (1), the 341 example code and OpenCV tutorial code is a great way to start. If you like (2), either pick up one of those books (if there's nothing available in the library, then perhaps a late nondenominational winter holiday present? or can you convince your team to buy it as a resource to you and future students?) or you can check out courses on Coursera or EdX - though be warned that these will probably quickly require a decent understanding of calculus and linear algebra.

Quote:
Originally Posted by yash101 View Post
So far, the only thing I've been able to accomplish is finding a certain color (which didn't work too well because I didn't have a colored object to track).
If you're going with the (1) experimentation route, I'd suggest that you define a specific project to work on sooner or later. Find a brightly-colored object around your house and try to track that - e.g. tennis balls can work well (more-so if they're newer).

Quote:
Originally Posted by yash101 View Post
Another thing I wonder about is whether to learn C, C++, Java or Python or maybe even something else.

One thing that I dislike about C is that the program will compile correctly. However, when I launch it, it will spit out just tons of fatal errors. How can I set the IDE (Visual Studio currently) to tell me that there are errors in the code? I have actually had my system hang because of a simple typo!
I'd recommend you steer away from C and C++ if you're not already very comfortable with them. Essentially, with great power comes great responsibility, and you'll want to be able to focus your efforts on working out the computer vision problems without making it even more complicated.

As Jared says, Python's more concise syntax will allow you to iterate faster than you would in Java. Java will probably have a little better performance, though if you're mostly just calling OpenCV functions and not trying to process the pixels yourself, this is much less of a concern. Go with whatever language is most comfortable for you.

Quote:
Originally Posted by yash101 View Post
Anyways, so I have an OpenCV C++ installation. How do I install the Java bindings?
The recent versions of the Windows prebuilt binaries have included the Java bindings in opencv\build\java. I haven't used it myself, but I believe you should be able to just include the .jar file in your classpath and the path to either the x86 or x64 .dll in the library path. Something like

Code:
java -Djava.library.path=C:\opencv\build\java\x64 -cp .;C:\opencv\build\java\opencv-247.jar MainClass
I believe 341 used JavaCV instead, which is another option.
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
  #8   Spotlight this post!  
Unread 04-01-2014, 01:08
Patrick Shainin Patrick Shainin is offline
Registered User
FRC #3238
Team Role: Mentor
 
Join Date: Dec 2013
Rookie Year: 2009
Location: Anacortes, Washington, USA
Posts: 5
Patrick Shainin is an unknown quantity at this point
Re: Best Way to Learn Vision Processing

It looks like the wpilib.screenstepslive links were changed when 2014 rolled in, and I don't see that same doc in the 2014 set. I'm posting it here for you. I found it helpful reading to get a handle on the generic approach I'm seeing used in other team's posted code.
Attached Files
File Type: pdf Vision_Processing.pdf (3.51 MB, 47 views)
  #9   Spotlight this post!  
Unread 04-01-2014, 15:52
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Best Way to Learn Vision Processing

Quote:
Originally Posted by RyanCahoon View Post
IMO, there are basically two ways to go about learning something. 1) you can pick a corner to start nibbling at and random-walk your way outward until you cobble together enough to solve the problem you're currently working on 2) you can go about trying to learn the big picture and theory of the entire subject, and then try to figure out how that applies to your current problem.

Jared and I gave you lists of topics to get started with also as a way to try to give you some direction about where to focus initially.

If you like (1), the 341 example code and OpenCV tutorial code is a great way to start. If you like (2), either pick up one of those books (if there's nothing available in the library, then perhaps a late nondenominational winter holiday present? or can you convince your team to buy it as a resource to you and future students?) or you can check out courses on Coursera or EdX - though be warned that these will probably quickly require a decent understanding of calculus and linear algebra.



If you're going with the (1) experimentation route, I'd suggest that you define a specific project to work on sooner or later. Find a brightly-colored object around your house and try to track that - e.g. tennis balls can work well (more-so if they're newer).



I'd recommend you steer away from C and C++ if you're not already very comfortable with them. Essentially, with great power comes great responsibility, and you'll want to be able to focus your efforts on working out the computer vision problems without making it even more complicated.

As Jared says, Python's more concise syntax will allow you to iterate faster than you would in Java. Java will probably have a little better performance, though if you're mostly just calling OpenCV functions and not trying to process the pixels yourself, this is much less of a concern. Go with whatever language is most comfortable for you.



The recent versions of the Windows prebuilt binaries have included the Java bindings in opencv\build\java. I haven't used it myself, but I believe you should be able to just include the .jar file in your classpath and the path to either the x86 or x64 .dll in the library path. Something like

Code:
java -Djava.library.path=C:\opencv\build\java\x64 -cp .;C:\opencv\build\java\opencv-247.jar MainClass
I believe 341 used JavaCV instead, which is another option.
I think I'll stick with C++ because I have a greater C knowledge than python or java. Also, it works on Windows with minimal configuration!
  #10   Spotlight this post!  
Unread 11-01-2014, 14:20
DavisC DavisC is offline
Registered User
FRC #0539 (Titans)
Team Role: College Student
 
Join Date: Jul 2011
Rookie Year: 2010
Location: Virginia
Posts: 200
DavisC is just really niceDavisC is just really niceDavisC is just really niceDavisC is just really nice
Re: Best Way to Learn Vision Processing

Quote:
Originally Posted by Patrick Shainin View Post
It looks like the wpilib.screenstepslive links were changed when 2014 rolled in, and I don't see that same doc in the 2014 set. I'm posting it here for you. I found it helpful reading to get a handle on the generic approach I'm seeing used in other team's posted code.
I have read through the document you attached as well as the (less filled) 2014 equivalent. (I am programming in C++)

I have also setup the Axis M1011 Camera (plugged into the D-Link, and it has a green ring light) so it has a brightness of ~10, and have it displaying on the driver station (would like to process it using the cRIO). I added a picture to the cRIO root directory (testimage.jpg) from the vision example program.

I loaded the 2014 Vision Code and ran Autonomous but nothing happened.

What should I do?
__________________
FRC Team 539
Student Member: 2010 Breakaway - 2014 Aerial Assist
Mentor: 2015 Recycle Rush - present
  #11   Spotlight this post!  
Unread 11-01-2014, 18:47
sparkytwd's Avatar
sparkytwd sparkytwd is offline
Registered User
FRC #3574
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Seattle
Posts: 102
sparkytwd will become famous soon enough
Re: Best Way to Learn Vision Processing

I strongly recommend the PS3 Eye camera. They can be had for ~$20 on Amazon. They're also proper computer vision cameras, as they're designed to work with the little glowing controller thing from Sony. You get:

* Up to 120fps capture
* Up to 640x480 resolution
* Good driver support on Windows and Linux
* 2 lens settings (50deg and 70deg FOV if memory serves)

The other cool thing with the Eye, is so popular you can get 3rd party lenses and IR imaging solutions for it. In 2012 my team had a pretty sophisticated CV approach, but at one competition our sensor was blinded by the stadium lighting being mounted directly behind the backboard. 2013 we switched to using infrared for the retro-illumination and did not have a repeat.
  #12   Spotlight this post!  
Unread 12-01-2014, 00:28
Patrick Shainin Patrick Shainin is offline
Registered User
FRC #3238
Team Role: Mentor
 
Join Date: Dec 2013
Rookie Year: 2009
Location: Anacortes, Washington, USA
Posts: 5
Patrick Shainin is an unknown quantity at this point
Re: Best Way to Learn Vision Processing

@DavisC: I haven't tried running the crio hosted vision code. To learn about vision processing, our team is taking the approach of writing algorithms using open cv on laptops and ironing out bugs there, then attempting to deploy to a second on-robot processor that would be running our code in either python or C++, and handing calculated results to the crio code. Sorry I don't have an answer for you about next steps with the approach your taking.
  #13   Spotlight this post!  
Unread 16-01-2014, 03:02
PaulDavis1968's Avatar
PaulDavis1968 PaulDavis1968 is offline
Embedded Software/Systems Engineer
AKA: Master of Complexity
FRC #2053 (TigerTronics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Endicot NY
Posts: 91
PaulDavis1968 is just really nicePaulDavis1968 is just really nicePaulDavis1968 is just really nicePaulDavis1968 is just really nicePaulDavis1968 is just really nice
Re: Best Way to Learn Vision Processing

I have read this book... http://simplecv.org/ . It is pretty good. I have in past season's used OpenCV 2.0 using C++ ( VS 2010 on windows 7 on a i3 core) and I have used SimpleCV on an Odriod-u2 (just bought the U3). I learned allot more about vision processing itself while using just OpenCV. Lots of tutorials and books. The main reason I learned more was because SimpleCV does allot of the work for you and it is a higher abstraction that is built on OpenCV. Like many abstractions they leak so it is good to know what is underneath. http://www.joelonsoftware.com/articl...tractions.html

We use SimpleCV because I know OpenCV (master beginner) and that makes me more productive. I am glad I started with OpenCV to learn simple vision processing but it is a steeper learning curve.

There is this and it is not cheap (though I did get Mathworks to get me a node locked copy for student use for our FIRST team of Matlab with all of the packages). http://www.petercorke.com/Machine_Vision_Toolbox.html

I also have access through work. It is not the cheapest way to learn vision but it is a common way in college and it can show you some advanced material and concepts.

I have looked at the code that comes with 2014. It is pretty much what we did as far as an algorithm last year to get distance in SimpleCV.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:34.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi