CAMERA BASICS 1 : FRAME GRABBING FROM CAMERA TO OLED

 

In this tutorial, we are going to take a look at how easy it is to grab a frame from a camera and push it to the OLED’s GRAM for displaying.


What you would need:

Hardware

  • BlazingCore100
  • 2.83” OLED w/ Touch Screen Interface Board
  • Embedded CMOS Camera (C3038)
  • Serial Comm.Key
  • Power Supply (6V – 12V DC)

Software
  • BCoreIDE


Introduction
The first thing that comes to people’s mind when you talk about vision systems if you’re doing it on a PC level is how difficult and expensive the entire system can be. On an open platform embedded level, sure the cost is significantly lower than its PC counterpart but the difficulty and the amount of reading you have to do prior to setting up and grabbing a single frame from the camera is one of the biggest hindrances to those wanting to add a vision element to their project.

Should you happen to be one of those looking for a way to add vision into your projects; this tutorial will prove helpful in demonstrating just how easy it is to get started.

For full details on the hardware and software used in this tutorial, head over to the download page and grab a copy of the datasheets and reference materials.

Hardware Setup

Setting up the BCore100 & OLED Board

OLED BCore connection

OLED BCore PinOut

Follow the Hardware Setup as illustrated below by stacking the boards on each other with the OLED and BCore Board Facing outwards; and the back of both boards facing each other on the inside.
TIP: Use the Pins parallel to the 4 JST connectors on the right to help align the two boards.

Touch Screen Hardware Setup

 Setting up the BCore100 & Camera Module

 BCore100 CAMERA SETUP

Connect the power supply and the Serial Comm.Key and that’s all the hardware we will be using.

Software Setup

  1. Launch BCoreIDE
  2. Enter your COM number assigned to your Comm.key
  3. Create a New Project
  4. Save Project

Programming the BCore100 to control the OLED and Camera

Now that that’s done, let’s start. Since we’ll need to display the image from the camera to the OLED screen, we’ll have to initialise the OLED and the Camera.

Initializing the OLED and Camera


BC CodeCode:

Public Sub Main()

'Init the OLED with a black background
OLED.Init(BCK.COLOUR.BLACK)
CAM.INIT() 'Init the Camera
CAM.WRITEREG(17,6) 'Set the SPEED of the camera to 6

End Sub

CAM.WRITEREG(register address, value) is a command that writes to the Camera’s Imaging Sensor Register, given the specified register address and the value in which to write into the register. In this case, the register address is 17 (0x11), which is the clock-rate control of OV6630; the value 6 is written to the clock rate control register, setting the speed of the camera to 6.
Note: Speed values range from 1 to 8, with 1 being the fastest and 8 being the slowest. By default, the
camera is initialised to speed 8.
Speed 6 is recommended speed and anything less than 6 is not advisable.

TIP: For more info, please refer to OV6630 datasheet, as well as the BCore Vision System Documentation.

Setting up a Frame Border


Next, we’ll declare 2 points to form a single pixel border around where we are going to draw the camera images to.  We do that by specifying the coordinates of both point structures, and then draw a rectangle using the 2 points. We then set the Camera’s drawing position to start drawing at coordinates (41, 1). The result? A really nice frame around the image being captured from the camera.


BC CodeCode:

DIM P1, P2 AS POINT
Public Sub Main()

OLED.Init(BCK.COLOUR.BLACK)
'Change the orientation of the OLED to portrait
OLED.Orientation = 1
CAM.INIT() 'Init the Camera
CAM.WRITEREG(17,6) 'Set the SPEED of the camera to 6

P1.X = 40
P1.Y = 0
P2.X = 201
P2.Y = 121
'DRAW A RECTANGLE AROUND THE CAPTURED IMAGE
OLED.DRAW.RECTANGLE(P1,P2)
'Set the position to draw the captured image to screen
CAM.POSITION(41,1)

End Sub

Frame Grabbing
The following code constantly grabs a frame from camera and pushes it to the OLED screen.
 

 

BC CodeCode:

DO
'GRAB THE IMAGE FORM THE CAMERA AND SEND IT TO THE OLED
CAM.GRABFRAME()
LOOP

CAM.GRABFRAME() instructs the camera to grab a single frame of image and push it to the OLED screen. By placing the instruction in a Do..Loop structure, the camera is instructed to do a frame capture again and again.  (Speed is set to 6, so we’ll get about 10 frames per second)

By default, the camera is set by the BCoreOS to capture a frame size of 160x120. The sizing may not exactly be big, but it’s big enough for most applications. (From line tracking to skin detection to character recognition)
To get a full screen camera capture, we will need to put in an external SRAM, but we’ll get to that some other time.

The full code should look something like this;

BC  CodeCode:

DIM P1, P2 AS POINT
Public Sub Main()

OLED.Init(BCK.COLOUR.BLACK)
'Change the orientation of the OLED to portrait
OLED.Orientation = 1
CAM.INIT() 'Init the Camera
CAM.WRITEREG(17,6) 'Set the SPEED of the camera to 6

P1.X = 40
P1.Y = 0
P2.X = 201
P2.Y = 121
'DRAW A RECTANGLE AROUND THE CAPTURED IMAGE
OLED.DRAW.RECTANGLE(P1,P2)
'Set the position to draw the captured image to screen
CAM.POSITION(41,1)

DO
'GRAB THE IMAGE FORM THE CAMERA AND SEND IT TO THE OLED
CAM.GRABFRAME()
LOOP

End Sub

 

And that’s it for the first part!

Try it out yourself! Tutorials and articles on the aforementioned applications mentioned in this tutorial will be posted up subsequently.

Keep checking back!

 


Download Source    Code Download PDF     Tutorial

 

 

 

 
Previous Next
Two New Tutorials
Learn how to control a Servo Motor with the FIDE, as well as adding a wireless peer-to-peer communication link using the EBlue Bluetooth Module.
Hoorah! We've Updated!
3 Cheers to a new tutorial, a FIDE patch, and a Language Reference Update!
New Sensor and Documentation Updates

 

We now carry the distance measuring sensor, SHARP GP2D12, WITH the compatible 3pin connector.

In other updates, we have uploaded the technical paper for our GLCD+RTC Combo complete with example configurations to our FlamingICE Boards. 

Our Hardware Reference now stands at version 1.5 with slight changes to the pin-outs on the FI28 Board. 

 

Christmas Updates

Download the latest FIDE v2.1 and get all the updated documentation that comes along with it!

Check out the new goodies that we have over at our updated Products Page!

Resource Page

Now that FIDE 2.0 is up, we published the Resource Page with 2 major tutorials to boot.

Start clicking and head over to check out those tutorials!

FIDE v2.0 RELEASED!

AIS Cube is proud to release the latest and most complete installment to date, FIDE v2.0. Delivering faster feature packed goodness, whats not to love?

Head over to the downloads tab and grab your copy!

FIDE v1.4.2 PATCH

IMPORTANT: Responding to a bug report, the FIDE v1.4.2 PATCH is a patch for a major bug fix in the FIDE SD Tool. Please ensure that you have FIDE v1.4.2 installed before proceeding with the Patch.

Patch is available over on the Downloads Tab.

FIDE v1.4 Released!
More features with the latest release of FIDE at version 1.4. Extended syntax highlighting range, greater support for FIDE system language instructions...
FIDE v1.3 Released!

FIDE v1.3 is now available for download over at the downloads tab. Featuring bug fixes and other features such as an expanded syntax highlighting coverage, it is highly recommended that you upgrade to the newest version.

AVRIL LE BOB

We have a new project named AVRIL LE BOB up over at the projects page (with videos!!). Check it out today!


Copyright © 2007-2008. AIS Cube. All Rights Reserved.
All trade and/or services marks mentioned are the property of their respective owners.
Joomla! is Free Software released under the GNU/GPL License.