diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e43b0f98 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/Week4/arduino/micro_speech_CASA/arduino_audio_provider.cpp b/Week4/arduino/micro_speech_CASA/arduino_audio_provider.cpp index a30829be..396d2175 100644 --- a/Week4/arduino/micro_speech_CASA/arduino_audio_provider.cpp +++ b/Week4/arduino/micro_speech_CASA/arduino_audio_provider.cpp @@ -1,19 +1,6 @@ -/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -==============================================================================*/ - -/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. +/* +Copyright 2018 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -26,7 +13,7 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -==============================================================================*/ +*/ #if defined(ARDUINO) && !defined(ARDUINO_ARDUINO_NANO33BLE) #define ARDUINO_EXCLUDE_CODE @@ -36,7 +23,8 @@ limitations under the License. #include "audio_provider.h" -#include "PDM.h" +#include "PDM.h" // https://www.arduino.cc/en/Reference/PDM Pulse Density Modulation + #include "micro_features_micro_model_settings.h" namespace { diff --git a/Week4/arduino/micro_speech_CASA/micro_features_micro_features_generator.cpp b/Week4/arduino/micro_speech_CASA/micro_features_micro_features_generator.cpp index 99b48358..8935d32c 100644 --- a/Week4/arduino/micro_speech_CASA/micro_features_micro_features_generator.cpp +++ b/Week4/arduino/micro_speech_CASA/micro_features_micro_features_generator.cpp @@ -13,6 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ + + +/* + Performs the FFT and returns the audio frequency information Ch.7 p145 +*/ + + #include "micro_features_micro_features_generator.h" #include diff --git a/Week4/arduino/micro_speech_CASA/micro_features_micro_features_generator.h b/Week4/arduino/micro_speech_CASA/micro_features_micro_features_generator.h index 29304239..afcfbec1 100644 --- a/Week4/arduino/micro_speech_CASA/micro_features_micro_features_generator.h +++ b/Week4/arduino/micro_speech_CASA/micro_features_micro_features_generator.h @@ -13,6 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ + +/* + Performs the FFT and returns the audio frequency information Ch.7 p145 +*/ + + #ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_MICRO_FEATURES_GENERATOR_H_ #define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_MICRO_FEATURES_GENERATOR_H_ diff --git a/Week5/arduino/TinyMLkit_CapturerawBytes/TinyMLkit_CapturerawBytes.ino b/Week5/arduino/TinyMLkit_CapturerawBytes/TinyMLkit_CapturerawBytes.ino new file mode 100644 index 00000000..71449ae5 --- /dev/null +++ b/Week5/arduino/TinyMLkit_CapturerawBytes/TinyMLkit_CapturerawBytes.ino @@ -0,0 +1,37 @@ +/* + 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 + +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); + } + Serial.println("Initialize camera!"); + + 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); +} diff --git a/Week5/arduino/processing/TinyMLKit_VisualiseRawBytes/TinyMLKit_VisualiseRawBytes.pde b/Week5/arduino/processing/TinyMLKit_VisualiseRawBytes/TinyMLKit_VisualiseRawBytes.pde new file mode 100644 index 00000000..f8561e95 --- /dev/null +++ b/Week5/arduino/processing/TinyMLKit_VisualiseRawBytes/TinyMLKit_VisualiseRawBytes.pde @@ -0,0 +1,82 @@ +/* + This sketch reads a raw Stream of RGB565 pixels + from the Serial port and displays the frame on + the window. + + Use with the Examples -> CameraCaptureRawBytes Arduino sketch. + + This example code is in the public domain. +*/ + +import processing.serial.*; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +Serial myPort; + +// must match resolution used in the sketch +final int cameraWidth = 176; +final int cameraHeight = 144; + +final int cameraBytesPerPixel = 2; + +final int bytesPerFrame = cameraWidth * cameraHeight * cameraBytesPerPixel; + +PImage myImage; + +void setup() +{ + size(176, 144); + + // if you have only ONE serial port active + //myPort = new Serial(this, Serial.list()[0], 9600); // if you have only ONE serial port active + + // if you know the serial port name + //myPort = new Serial(this, "COM3", 9600); // Windows + //myPort = new Serial(this, "/dev/ttyACM0", 9600); // Linux + myPort = new Serial(this, "/dev/cu.usbmodem14701", 9600); // Mac + + // wait for full frame of bytes + myPort.buffer(bytesPerFrame); + + myImage = createImage(cameraWidth, cameraHeight, RGB); +} + +void draw() +{ + image(myImage, 0, 0); +} + +void serialEvent(Serial myPort) { + byte[] frameBuffer = new byte[bytesPerFrame]; + + // read the saw bytes in + myPort.readBytes(frameBuffer); + + // create image to set byte values + PImage img = createImage(cameraWidth, cameraHeight, RGB); + + // access raw bytes via byte buffer + ByteBuffer bb = ByteBuffer.wrap(frameBuffer); + bb.order(ByteOrder.BIG_ENDIAN); + + int i = 0; + + img.loadPixels(); + while (bb.hasRemaining()) { + // read 16-bit pixel + short p = bb.getShort(); + + // convert RGB565 to RGB 24-bit + int r = ((p >> 11) & 0x1f) << 3; + int g = ((p >> 5) & 0x3f) << 2; + int b = ((p >> 0) & 0x1f) << 3; + + // set pixel color + img.pixels[i++] = color(r, g, b); + } + img.updatePixels(); + + // assign image for next draw + myImage = img; +} diff --git a/Week6/edgeimpulse.zip b/Week6/edgeimpulse.zip deleted file mode 100644 index b4436c66..00000000 Binary files a/Week6/edgeimpulse.zip and /dev/null differ diff --git a/Week6/helpers/play.py b/Week6/helpers/play.py index 72dd9bce..c5a8510f 100644 --- a/Week6/helpers/play.py +++ b/Week6/helpers/play.py @@ -20,7 +20,7 @@ if filename.endswith(".wav"): song = AudioSegment.from_wav(os.path.join(directory, filename)) play(song) - time.sleep(10) + time.sleep(2) continue else: continue \ No newline at end of file