Skip to content

[PC-1807] Vision Shield Rev 2 - Tutorials Revamp with new camera #2138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,21 @@ Connect the Portenta Vision Shield to your Portenta H7 as shown in the figure. T

#### The Camera

You will be using the **Himax HM-01B0 camera module** which has a resolution of 320 by 240 and the output data its in grayscale with 8 bits per pixel (bpp). It is important to have this in mind as the `.bmp` (bitmap) format has some needed configuration depending on the data being used.
The Vision Shield Rev.1 uses the **Himax HM-01B0 (320x240) camera module**, the Vision Shield Rev.2 uses the **Himax HM0360 (640x480) camera module**, both output data are grayscale with 8 bits per pixel (bpp). It is important to have this in mind as the `.bmp` (bitmap) format has some needed configuration depending on the data being used.

Inside the sketch, you can use these libraries to access the camera APIs, also compatible with the [Arduino Nicla Vision](https://docs.arduino.cc/hardware/nicla-vision)
```cpp
#include "camera.h" // Multi Media Card APIs
#include "himax.h" // API to read from the Himax camera found on the Portenta Vision Shield

//For the Vision Shield Rev.1
#include "himax.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.1

//For the Vision Shield Rev.2
#include "hm0360.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.2
```

***Left uncommented the library of your Vision Shield version.***

#### Bitmap File Format

The bitmap binary file needs to contain some information in order to tell the computer for example the resolution of the picture and the bit-depth (bpp). Bit depth refers to the color information stored in the image. The higher the bit depth of an image, the more colors it can store. As the bit depth increases, the file size of the image also increases, because more color information has to be stored for each pixel in the image.
Expand Down Expand Up @@ -80,7 +87,12 @@ First you need to include the needed libraries
#include "FATFileSystem.h" // Mbed API for portable and embedded systems

#include "camera.h" // Arduino Mbed Core Camera APIs
#include "himax.h" // API to read from the Himax camera found on the Portenta Vision Shield

/*-----Uncomment the library and class for your specific hardware-----*/

//#include "himax.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.1
// OR
#include "hm0360.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.2
```

Then define the following objects with their respective constructor (`blockDevice` and `fileSystem` objects), needed for getting access to the SD Card and the file system.
Expand All @@ -92,8 +104,17 @@ SDMMCBlockDevice blockDevice;
mbed::FATFileSystem fileSystem("fs");

#include "camera.h" // Arduino Mbed Core Camera APIs
#include "himax.h" // API to read from the Himax camera found on the Portenta Vision Shield
HM01B0 himax;

/*-----Uncomment the library and class for your specific hardware-----*/

//#include "himax.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.1
//HM01B0 himax;

// OR

#include "hm0360.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.2
HM0360 himax;

Camera cam(himax);

FrameBuffer frameBuffer; // Buffer to save the camera stream
Expand Down Expand Up @@ -288,8 +309,15 @@ SDMMCBlockDevice blockDevice;
mbed::FATFileSystem fileSystem("fs");

#include "camera.h" // Arduino Mbed Core Camera APIs
#include "himax.h" // API to read from the Himax camera found on the Portenta Vision Shield
HM01B0 himax;

/*-----Uncomment the library and class for your specific hardware-----*/

//#include "himax.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.1
//HM01B0 himax;

#include "hm0360.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.2
HM0360 himax;

Camera cam(himax);

FrameBuffer frameBuffer; // Buffer to save the camera stream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,23 @@ To capture the frames you will need to use the functions contained in `camera.h`

```cpp
#include "camera.h"
#include "himax.h"
//For the Vision Shield Rev.1
//#include "himax.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.1

//For the Vision Shield Rev.2
#include "hm0360.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.2
```

***Left uncommented the library of your Vision Shield version.***

Next, let's initialize a camera object and a frame buffer of the size 320*240 (76'800 bytes).

```cpp
HM01B0 himax;

//HM01B0 himax; // for Vision Shield Rev.1

HM0360 himax; // for Vision Shield Rev.2

Camera cam(himax);
#define IMAGE_MODE CAMERA_GRAYSCALE
FrameBuffer fb(320,240,2);
Expand Down Expand Up @@ -268,9 +278,15 @@ The `CaptureRawBytes.ino` Sketch.

```cpp
#include "camera.h"
#include "himax.h"

HM01B0 himax;
/*-----Uncomment the library and class for your specific hardware-----*/

//#include "himax.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.1
//HM01B0 himax;

#include "hm0360.h" // API to read from the Himax camera found on the Portenta Vision Shield Rev.2
HM0360 himax;

Camera cam(himax);
#define IMAGE_MODE CAMERA_GRAYSCALE
FrameBuffer fb(320,240,2);
Expand Down