Go to Post [when asked where to learn about robot parts] ...some forum called Chief Delphi. I hear the people there are pretty knowledgeable about this robotics thing. - EricH [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average. Display Modes
  #1   Spotlight this post!  
Unread 02-02-2012, 02:32
jviolette123 jviolette123 is offline
Registered User
FRC #1318
 
Join Date: Feb 2012
Location: Issaquah, WA
Posts: 10
jviolette123 is on a distinguished road
JavaCV and OpenCV Camera Calibration with sample code

This document contains a procedure to calibrate an Axis Camera using JavaCV and OpenCV.

The procedure starts with nothing, and walks through the camera setup, JavaCV and OpenCV installation, plus a description of the three sample JavaCV calibration programs (frames per second, manual calibration, automated chessboard calibration).

Also included is a PPT of our 'chessboard', in a zip file since this forum does not recognize pptx files.
Attached Files
File Type: docx Calibrating an Axis Camera using JavaCV and OpenCV.docx (949.3 KB, 1343 views)
File Type: zip smallChessboard.zip (30.3 KB, 673 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 02-02-2012, 08:33
Greg McKaskle Greg McKaskle is online now
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: JavaCV and OpenCV Camera Calibration with sample code

I'm curious if you found it necessary to do the calibration? NI IMAQ has a similar calibration procedure, but for simplicity, I haven't bothered to include it.

In other words, what forms of image processing failed without the calibration and worked afterwards?

Greg McKaskle
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2012, 11:33
jviolette123 jviolette123 is offline
Registered User
FRC #1318
 
Join Date: Feb 2012
Location: Issaquah, WA
Posts: 10
jviolette123 is on a distinguished road
Re: JavaCV and OpenCV Camera Calibration with sample code

We calibrated the camera to remove the barrel distortion.

We are counting pixels to determine height and width for the backboard rectangle. From the height and width in pixels, we can determine range and bearing between the camera and the backboard.

Using a radial target pattern, we determined there was a 25% difference in pixel count at the center of the camera and the edge of the camera field of view. Specifically, 41 pixels per cm at the center and 31 pixels per cm at the edge.

An error of up to 25% due to the backboard placement in the field of view would lead to range errors greater than the diameter of the hoop, and so we would not be able to determine how far to launch the ball.

If we were to reduce the distortion error, our subsequent calculations for range and bearing would improve and our chances of launching the ball on the correct trajectory would be much better.
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2012, 01:09
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: JavaCV and OpenCV Camera Calibration with sample code

This is huge help. It was on my list of "NEXT" to do.
Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2012, 07:56
Greg McKaskle Greg McKaskle is online now
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: JavaCV and OpenCV Camera Calibration with sample code

25% is a pretty big difference.

The white paper contained a pretty full shot of the target. I attached it again below. The target doesn't go entirely to the edge of the screen, but pretty close. Quick measurements there on the rectangle have it at 200pixels on one vertical edge, 209 on the other, and 216 in the center. I honestly can say for sure which camera the shot was taken with any longer since I carry both in my bag. What camera were you measuring?

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	field 33 .jpg
Views:	154
Size:	12.5 KB
ID:	11731  
Reply With Quote
  #6   Spotlight this post!  
Unread 07-02-2012, 03:27
jviolette123 jviolette123 is offline
Registered User
FRC #1318
 
Join Date: Feb 2012
Location: Issaquah, WA
Posts: 10
jviolette123 is on a distinguished road
Re: JavaCV and OpenCV Camera Calibration with sample code

We are using Axis 1011.

Check out these images for comparison. One is the original, the other is after the correction. Look at the edges to see how many pixels off the edges are. When the image is up close, errors are insignificant (more pixels to get the distance). As the robot moves away from the hoops, the rectangle gets smaller in the frame, and moves towards the edges.

Check out this radial shot and measure the pixels per cm between rings 1-2 and the pixels per cm between rings 7-8.
Attached Thumbnails
Click image for larger version

Name:	10.jpg
Views:	185
Size:	83.3 KB
ID:	11784  Click image for larger version

Name:	undistort.jpg
Views:	160
Size:	29.3 KB
ID:	11785  Click image for larger version

Name:	20120112_16-06-08.jpg
Views:	136
Size:	57.5 KB
ID:	11786  
Reply With Quote
  #7   Spotlight this post!  
Unread 07-02-2012, 03:37
jviolette123 jviolette123 is offline
Registered User
FRC #1318
 
Join Date: Feb 2012
Location: Issaquah, WA
Posts: 10
jviolette123 is on a distinguished road
Re: JavaCV and OpenCV Camera Calibration with sample code

Suppose your camera was a somewhere in mid-field.

If the camera were looking directly at the backboard, that is, your rectangle is in the center of the field of view, then you would get a large reading for the pixel count, indicating you are close to the backboard.

If the camera were looking off to the side, then your rectangle is at the edge of the field of view. The rectangle would be smaller by up to 25% in pixel count than at the center. Any calculation based on that smaller number would say that you are farther than you really are.

The answer you get at the same distance depends on where the backboard is in the field of view. You can correct for that after the fact, or you can correct the image in the first place. We chose to correct the image.
Reply With Quote
  #8   Spotlight this post!  
Unread 07-02-2012, 07:47
Greg McKaskle Greg McKaskle is online now
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: JavaCV and OpenCV Camera Calibration with sample code

I understand what calibration is and the benefits, but I had assumed that it was rather expensive, and not all that necessary.

Do you expect the robot to shoot at targets near the edge of the camera?

Greg McKaskle
Reply With Quote
  #9   Spotlight this post!  
Unread 07-02-2012, 12:13
jviolette123 jviolette123 is offline
Registered User
FRC #1318
 
Join Date: Feb 2012
Location: Issaquah, WA
Posts: 10
jviolette123 is on a distinguished road
Re: JavaCV and OpenCV Camera Calibration with sample code

Depending on the robot's distance from the backboard, the rectangle moves up and down in the field of view. Also, depending on the tilt of the camera, the rectangle may be anywhere on a vertical line at the time of launch. We should be able to get the side to side alignment fairly close.

Some correction due to vertical placement seems to be required. Depending on the processing configuration, when this happens might change. If the cRio is doing the image work, it may be reasonable to do this correction after the fact. A coprocessor off the cRio may have enough cycles to correct up front, and simplify the geometric calculations.
Reply With Quote
Reply


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 09:36.

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