-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from tinyMLx/addingLibraryFeatures
Adding library features and OV767X Library
- Loading branch information
Showing
17 changed files
with
3,767 additions
and
83 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
# arduino-library | ||
# Harvard_TinyMLx Arduino Library | ||
|
||
Source code and examples for using and testing your Tiny Machine Learning Kit and Shield. | ||
|
||
This library also includes a modified verison of the 0.0.2 version of the OV767X Library for Arduino (Copyright (c) 2020 Arduino SA) which is based on https://www.kernel.org[Linux Kernel's] V4L2 driver for OmniVision OV7670 cameras - which was created by Jonathan Corbet. | ||
|
||
== License == | ||
|
||
Copyright (c) 2021 TinyMLx. All rights reserved. | ||
|
||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2. | ||
|
||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
OV767X - Camera Test Pattern | ||
This sketch waits for the letter 'c' on the Serial Monitor, | ||
it then reads a frame from the OmniVision OV7670 camera and | ||
prints the data to the Serial Monitor as a hex string. | ||
The website https://rawpixels.net - can be used the visualize the data: | ||
width: 176 | ||
height: 144 | ||
RGB565 | ||
Little Endian | ||
Circuit: | ||
- Arduino Nano 33 BLE board | ||
- OV7670 camera module: | ||
- 3.3 connected to 3.3 | ||
- GND connected GND | ||
- SIOC connected to A5 | ||
- SIOD connected to A4 | ||
- VSYNC connected to 8 | ||
- HREF connected to A1 | ||
- PCLK connected to A0 | ||
- XCLK connected to 9 | ||
- D7 connected to 4 | ||
- D6 connected to 6 | ||
- D5 connected to 5 | ||
- D4 connected to 3 | ||
- D3 connected to 2 | ||
- D2 connected to 0 / RX | ||
- D1 connected to 1 / TX | ||
- D0 connected to 10 | ||
This example code is in the public domain. | ||
*/ | ||
|
||
#include <Arduino_OV767X.h> | ||
|
||
unsigned short pixels[176 * 144]; // QCIF: 176x144 X 2 bytes per pixel (RGB565) | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
while (!Serial); | ||
|
||
Serial.println("OV767X Camera Capture"); | ||
Serial.println(); | ||
|
||
if (!Camera.begin(QCIF, RGB565, 1, OV7675)) { | ||
Serial.println("Failed to initialize camera!"); | ||
while (1); | ||
} | ||
|
||
Serial.println("Camera settings:"); | ||
Serial.print("\twidth = "); | ||
Serial.println(Camera.width()); | ||
Serial.print("\theight = "); | ||
Serial.println(Camera.height()); | ||
Serial.print("\tbits per pixel = "); | ||
Serial.println(Camera.bitsPerPixel()); | ||
Serial.println(); | ||
|
||
Serial.println("Send the 'c' character to read a frame ..."); | ||
Serial.println(); | ||
} | ||
|
||
void loop() { | ||
if (Serial.read() == 'c') { | ||
Serial.println("Reading frame"); | ||
Serial.println(); | ||
Camera.readFrame(pixels); | ||
|
||
int numPixels = Camera.width() * Camera.height(); | ||
|
||
for (int i = 0; i < numPixels; i++) { | ||
unsigned short p = pixels[i]; | ||
|
||
if (p < 0x1000) { | ||
Serial.print('0'); | ||
} | ||
|
||
if (p < 0x0100) { | ||
Serial.print('0'); | ||
} | ||
|
||
if (p < 0x0010) { | ||
Serial.print('0'); | ||
} | ||
|
||
Serial.print(p, HEX); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
OV767X - Camera Capture Raw Bytes | ||
This sketch reads a frame from the OmniVision OV7675 camera | ||
and writes the bytes to the Serial port. Use the Procesing | ||
sketch in the extras folder to visualize the camera output. | ||
This example code is in the public domain. | ||
*/ | ||
|
||
#include <Arduino_OV767X.h> | ||
|
||
int bytesPerFrame; | ||
|
||
byte data[176 * 144 * 2]; // QVGA: 320x240 X 2 bytes per pixel (RGB565) | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
while (!Serial); | ||
|
||
if (!Camera.begin(QVGA, RGB565, 1, OV7675)) { | ||
Serial.println("Failed to initialize camera!"); | ||
while (1); | ||
} | ||
|
||
bytesPerFrame = Camera.width() * Camera.height() * Camera.bytesPerPixel(); | ||
|
||
// Optionally, enable the test pattern for testing | ||
// Camera.testPattern(); | ||
} | ||
|
||
void loop() { | ||
Camera.readFrame(data); | ||
|
||
Serial.write(data, bytesPerFrame); | ||
} |
Oops, something went wrong.