Commit Graph

185 Commits

Author SHA1 Message Date
Kwabena W. Agyeman
11983a0228 Add wifi_dbg stub.
All the notes about how to implement wifi programming are in the code.
Steps:

1. Get wifi_apply_settings() working first and make sure you can turn
the wifi shield on in the right mode. Then add the necessary hooks into
the network code to make it such that previous user wifi code still
works. Also, make sure to handle start and shutdown gracefully.

Basically, get all the lifecycle code working first before moving to the
next step so notning gets in a weird state and bugs creep in...

2. Get the beacon method working. Once this works OpenMV IDE should see
the camera when you hit the connect button.

3. Do the code to turn off the regular usbdbg interface and swtich to
having the data come from wifi_dbg. This isn't a lot of code... but,
will be tricky since you no longer will have USB frames to work with.
All bytes are just going to come randomly and in bursts so you have to
handle the serial stream yourself... (Kwabena can help writing a
statemachine for dealing with this type of stuff if you want. I do it
all the time).
2018-02-08 01:49:29 -05:00
iabdalkader
9a2bf08c50 Move line functions to line.c 2018-02-06 02:07:36 +02:00
iabdalkader
6d396b809a Enable auto dependency generation. 2018-02-04 18:31:39 +02:00
Kwabena W. Agyeman
5377f6f575 Add single image shadow remover code.
Calling remove_shadows() on an image without a background source of
truth image now works. However, that said, the shadow remover isn't
suitable for anything other than removing shadow on an image of concrete
flow or somthing of the like. In general, it can only remove shadows
from a scene that has nothing else in it except for a hard edge shadow.

Improving this to work for anything is about a month of work. I've
researched enough about shadow removal to now know the optimal way to do
it. However, it requires many steps and a large amount of RAM. On the H7
I may revist this as being possible.

...

In order to get the shadow remover working well I had to add a few
features to the image library and fix some of the convolution code.
These fixes will likely be more useful than the shadow removal code.

Note the addition of the new get_threshold() method. This computes
otsu's threshold on a histogram allowing you to pick the optimal color
bounds.
2018-01-28 19:33:04 -05:00
Kwabena W. Agyeman
bfcdcd4793 Add REPL Uart Ini File Setting Support
OpenMV IDE includes an ini file generator which will let you set board
settings easily from the IDE. Currently, the IDE has support for setting
the WiFi shield up along with adding a REPL Uart.

Anyway, this commit adds support for the OpenMV Cam to parse an ini file
on startup to configure things before starting main.py. WiFi support is
not yet implmented. However, we now have the ability to turn the UART
and put the REPL terminal on it on startup given a setting in the ini
file.

(Why not use boot.py like normal MP? While that is more flxible it's
much harder for the IDE to easily write out settings for you which is
what most users will want to do versus coding this up).

...

The movitation for adding REPL UART support in particular is so that the
OpenMV Cam can be used as a slave processor to IoT type processors like
the ESP32/ESP8266/ParticlePhoton/ElectricImp. In particular, a processor
like the ParticlePhoton can control the OpenMV Cam's reset wire. Wake
the camera up by releasing reset, then send a script to it after it
powers on over the UART. The camera will then run the script, do
computer vision, and report results back over the UART to the
ParticlePhoton. Users can then push new scripts to the OpenMV Cam from
the cloud allowing for semi-flexible firmware fixes for the OpenMV Cam
over low data rate networks.

By setting this feature up the need for OpenMV to offer a WiFi IoT
system is reduced as we can now just be the best camera for everything.

...

Due to... I don't know... ctrl-c doesn't work on the duplicated UART.

https://github.com/micropython/micropython/issues/1568

Not sure how to handle this. I don't want to fix it since it needs to be
fixed by MP upstream. Right now the work around is for the mastering MCU
to just reset the OpenMV Cam when it's done with the system.

That said, this does mean that once you start a script using the Open
Terminal command line system you won't be able to stop the script.
2018-01-23 00:22:23 -05:00
iabdalkader
a51e0de410 Copy USB code to bootloader.
* The bootloader will be more self-contained.
2017-12-24 21:24:25 +02:00
iabdalkader
9cb0ca0b9a Add no-strict-aliasing to STHAL CFLAGS. 2017-12-24 17:21:08 +02:00
Ibrahim Abd Elkader
6753b93842
Merge pull request #286 from kwagyeman/compare_methods
Add a LUT for illuminvar()
2017-12-24 17:24:31 +02:00
Kwabena W. Agyeman
f2c36e780a Add a LUT for illuminvar()
It's now faster to be more useful.

Need to work on HDR for the sensor and making the sensor output better.
I fixed some issues with the illuminvar() method going crazy when it
gets colors with values near 0... but, the shot noise from the sensor
adds a lot of noise to everything. Fixing this will likely solve a lot
of algorithm problems.
2017-12-23 21:16:55 -05:00
iabdalkader
f79c6ba8d2 Move linker script variables to board config files. 2017-12-04 20:43:49 +02:00
iabdalkader
8160e9120e Add MT9V034 initial support. 2017-10-24 03:07:17 +02:00
iabdalkader
04a14a290f Rename SCCB/I2C driver to cambus. 2017-10-18 23:14:14 +02:00
iabdalkader
46da0d9f2f Add roundf to Makefiles. 2017-10-09 21:32:03 +02:00
iabdalkader
11bed4b993 Update to MP-1.9.2 2017-10-09 21:20:06 +02:00
iabdalkader
64143d4a94 Remove frozen code object file. 2017-10-06 01:37:44 +02:00
iabdalkader
bb0d0e778a Disable OPENMV 1 build. 2017-10-02 00:27:03 +02:00
iabdalkader
e2514ee302 Add pendsv debugging flags to top Makefile. 2017-09-23 15:46:06 +02:00
iabdalkader
3ccc418cf3 Update main Makefile for MP 1.9 2017-09-21 16:58:57 +02:00
Kwabena W. Agyeman
5a3153c8b9 Find line segments more stable
Switched the find line segments algorithm to something more stable using
the standard LSD algorithm that's used by OpenCV.
2017-09-13 00:33:31 -04:00
iabdalkader
200ffeed58 Add LeNet! 2017-07-11 04:10:40 +02:00
Kwabena W. Agyeman
f9e124f8cd Refactor framebuffer
Moved structs along with image copying code from sensor into
framebuffer.c so that we can use the new copy_fb_to_jpeg_fb() function
in the image library for methods with "copy_to_fb" so that they update
the IDE preview when called.

Also, I noticed that the MAIN_FB_SIZE() value is not calculated
correctly in all cases. Will fix later. Trying to keep this commit clean
for just the refactoring.

All changes have been tested. Too.
2017-06-10 23:31:42 -04:00
Kwabena W. Agyeman
690ec923ae Add data matrix support.
Add support for decoding data matrices and example scripts.
2017-04-28 19:58:19 -04:00
Kwabena W. Agyeman
35e9f988d6 Refactor umm_malloc into it's own file.
We now have a nice and fast malloc system that easily offers 300KB+
dynamic memory... No need to use xalloc anymore except when we're
transfering objects to MP memory space.
2017-04-26 22:48:52 -04:00
iabdalkader
2c4ec23244 Fix gcc2016q4 warnings.
* Fixed misleading indentation.
* Removed unused static variables.
* Disabled strict aliasing for STM DSP library.
2017-04-23 20:40:07 +02:00
Kwabena W. Agyeman
bfd048e6f3 Integrate ZBar 2/2
ZBar functionality integrated along with an example script.
2017-03-24 12:45:27 -04:00
iabdalkader
2934e88146 Enable CAN2 for OMV2 and OMV3 2017-02-23 15:04:04 +02:00
iabdalkader
f0a389f2cc Enable extra MP modules. 2017-02-23 02:15:04 +02:00
Kwabena W. Agyeman
443ba3bff8 AprilTags Support
Works super good.
2017-02-09 17:37:18 -05:00
iabdalkader
e2d0c48401 Replace FREAK with ORB.
* New keypoints descriptor, much better implementation than FREAK.
2017-01-04 05:44:06 +02:00
iabdalkader
cf1407cb48 Add AGAST corner detector. 2017-01-03 20:36:08 +02:00
Kwabena W. Agyeman
6a8ce01e79 Add QRCode detection.
Use the qrcodes script and point your OpenMV Cam at google search
results for QR Codes.
2016-12-27 15:30:35 -05:00
Kwabena W. Agyeman
b668ac7e17 Add collections. 2016-12-27 14:04:30 -05:00
iabdalkader
cafddfed17 Redefine CFLAGS MCU_SERIES in the top Makefile.
* Make sure the MCU_SERIES is defined if MP config files are included outside MP build.
2016-12-14 13:55:53 +02:00
iabdalkader
3e41450d97 Add support for OpenMV3 2016-11-27 19:32:09 +02:00
iabdalkader
b4aeb32e1b Add build option to enable stack protection. 2016-11-15 19:07:50 +02:00
iabdalkader
ef6e6303c7 Add HoG. 2016-10-10 17:22:04 +02:00
iabdalkader
60dc3f7e91 Remove ToF module. 2016-10-10 16:53:02 +02:00
iabdalkader
e104be63df Implement Canny edge detector. 2016-09-13 02:37:43 +02:00
iabdalkader
83451de050 Add Hough Transform. 2016-09-12 22:16:58 +02:00
iabdalkader
f5e1028786 Add sin/cos tables. 2016-09-11 17:01:53 +02:00
iabdalkader
faf79007c9 Add DEBUG_PRINTF flag 2016-08-30 22:37:22 +02:00
iabdalkader
56438bc079 Add cpufreq module.
* Add CPU frequency scaling module and example script.
2016-08-17 19:42:05 +02:00
iabdalkader
1cbcb7e434 Add M7 support 2016-08-12 22:43:50 +02:00
iabdalkader
0363fa8758 Add ToF module. 2016-07-27 15:21:33 +03:00
Kwabena W. Agyeman
7af818c4d8 Finished up optical flow code.
* Added pooling functions to make getting small images easy. set_binning
works too... but, it zooms in way to much. pooling functions aout you to
shrink the image while not zooming in.

* To make the pooling functions easy to use I created a version that
pools the image out of place and one that pools the image in place. The
inplace pooling function can work on the frame buffer (see edits to
sensor.c)

* I added the code to do hann windowing to the FFT lib. However, I
commented it out after it improved performance by basically zero.
Specialized windowing stuff will only come in handy for folks trying to
tune their algorithm... not in general for everything.

* I added subpixel resolution for the phase correlation code. You can
now track the image movement really precisely. Additionally, I fixed up
the displacement outputs to give expected results. I also added a QoR
output for the displacement code so that you can know when the results
are bad.

* Finally, an example script has been added to show off the features.
2016-06-18 23:05:44 -04:00
Kwabena W. Agyeman
45fdcc973e Add FFT Code and Phase Correlation Code
The heart of the 1D FFT works. I tested this on the PC. However, 2D FFTs
may have issues and the phase correlation algorithm does not generate
the expected results. That said, most of the work is done. Stuff just
needs to be deubgged.

The FFT lib is designed to handle up to 1024 point real FFTs and 512
complex FFTs. As for 2D FFTs, we can do up to 64x64 pixels. After which,
we don't have enough RAM to handle them because they use up about 128KB
each.

Things to do... the 2D FFT needs to be verified. So, we need to run an
image through it and then back again to verify that there are no
problems. Then we need to compare the 2D FFT output with another 2D FFT
algorithm on the PC...

Once the FFTs are known to be good we then need to make sure the phase
corelation algorithm outs the correct results. We need to test that with
multiple shifted images, etc.
2016-06-12 19:55:45 -04:00
iabdalkader
318b67da42 Fix typo. 2016-05-25 03:42:57 +02:00
iabdalkader
2e2c563227 Re-implement line filters with Python callbacks. 2016-05-16 14:22:30 +02:00
iabdalkader
a865075e85 Fix Makefile dependencies.
* Fixes issue with parallel builds (make -jn)
2016-05-12 14:28:27 +02:00
iabdalkader
f61d89e0a4 Fix Makefile Verbosity.
* Make build more quite.
2016-05-12 14:01:14 +02:00
iabdalkader
23f1935924 Enable modmachine. 2016-05-12 12:53:55 +02:00
iabdalkader
ba73787c8a Use MicroPython's SD Card Module. 2016-05-11 18:46:38 +02:00
iabdalkader
9a5992c03e Update code for MP v1.8 2016-05-09 21:46:29 +02:00
iabdalkader
1f150c1847 Cleanup Makefile.
* Rename binary files.
* Misc cleanups
2016-05-03 19:16:43 +02:00
iabdalkader
a314b59d1a Generate a combined binary for the programming jig. 2016-05-03 16:12:52 +02:00
iabdalkader
6b581af1b1 Add mass erase to make flash. 2016-04-29 20:32:14 +02:00
iabdalkader
cadb73eb5e Fix Makefile build order. 2016-04-26 22:58:07 +02:00
iabdalkader
3d38908f2a Update main Makefile
* Add bootloader sources.
* Generate main FW image dfu, bootloader dfu and combined dfu image.
2016-04-25 18:20:20 +02:00
Kwabena W. Agyeman
401b7b72a8 Added mean, median, and mode filters.
Mean filter -> Fast and easy to use. This will likely be the only filter
that gets alot of action on the M4.

Median filter -> Works really well, but, slow. On grayscale at 160x120
you can get also 10 FPS with it for a 3x3 kernel. That said, it's still
slow. Also, the code only works for 3x3 and 5x5 kernels.

About the previous histogram filter... technically, that filter should be
better. However, it suffers from a startup cost. The operation of finding
the median point in the histogram costs too much to compute. This is
what causes it to be slow. On very large kernels it will be faster than
the sorting median alrogithm I put up... but, large kernels will be too
slow for anyone to use anyway. The paper Ibrahim linked to about it
showed it being used for like 7x7 kernels and up... so, I think the
researcher who thought of the idea was really thinking about the
algorithm for large kernels.

Mode filter -> Works great on grayscale. Not so much on color. I think it
needs to be run on the LAB color space instead of the RGB color space. I
say this because it causes pretty strong artifacts around edges. When we
get more flash we'll be able to have a reverse lookup table for LAB to
make the mode filter better. Until then...
2016-04-04 20:04:50 -04:00
iabdalkader
4e31f25db8 Additional qstr definitions for OpenMV. 2016-03-29 02:26:39 +02:00
Kwabena W. Agyeman
978b4c12df Add Midpoint filter.
Has a bias value that allows you to control if its really a midpoint,
min, max filter, or something inbetween. Run at 160x120 or lower. 320x240
is slow (seems to be the case for all convoltions at that res).
2016-03-25 21:26:20 -04:00
iabdalkader
b92f146323 Add initial WINC1500 WiFi module driver.
* Note: partial implemented, based on CC3000 module (only scan, connect, ifconfig work)
2016-03-26 01:52:29 +02:00
Kwabena W. Agyeman
88907c438c Redid MLX Code
First, a few things:

The MLX 16x4 sensor has just too low of a resolution for mass appeal for
the price. The product is not going to sell very well. We need to look
into supporting sensors with a better res. Like the FLIR 1. The MLX
module was renamed to the "flir" module with this idea in mind.

The flir code now takes care of doing scaling and blending itself. I did
this to get rid of the user having to scale the image themselves and
blend themselves. Its too easy to run out of memory given our current
ultra small heap. In general, anything that requires multiple images in
RAM has got to go. When we do another OpenMV Cam with external RAM in
the MB range then maybe such functions will be safe. But, right now they
are definately not.

Anyway, moving on, I fixed a few bugs with the MLX math code. But, for
the most part was correct. I also added reconmended polling code for
brownouts as required by the datasheet.

Last, I designed this code like the LCD code to support a type value
when inited. This will allow the system to user a different sensor in the
future without any API changes to the user.

I will add test scripts for this next. Basic usage follows:

import flir
flir.init()
flir.display_ir(sensor.snapshot())

And that's it. Super easy. If the user wants the raw temp values they
can use flir.read_ir() to get the ta and to values. The display function
has a hidden alpha and scale argument for controling blending and the
min/max scaling.

The previous way we worked out scaling kinda sucked... it was a good
shot, but, controllable min and maxes that autoscale by default just
work better. If the user knows the temp range then they can just set the
min and max.'

Anyway, longest commit ever done.
2016-03-24 18:04:05 -04:00
Kwabena W. Agyeman
94910c8ed7 Move LCD code into module. It's now ultra fast, safe and friendly. I
tested everything too and added an example script (very simple).
2016-03-17 20:01:03 -04:00
Kwabena W. Agyeman
5316b26d83 Added a new mjpeg module for Mjpeg support.
The built-in mjpeg module allows you to record videos seamlessly. It
will automatically compress the frame buffer using the extra space in the
main ram. So... you don't have to pass it jpeg images. Gets 7 FPS at
320x240 while connected to the computer too (it has to compress the
frame twice in this situation).

Anyway, the module work like Gif.
2016-03-05 20:03:48 -05:00
Kwabena W. Agyeman
488253a8b0 Add statistics function.
You can now get the color stats for an area in the image. The stats
function returns the mean, median, mode, min, max, st_dev,
lower_quartile, and upper_quartile.

This function allows you to automate binary and threshold functions
based on what's in the iamge.
2016-03-01 21:43:52 -05:00
Kwabena W. Agyeman
98f4dde21f Add new morph function.
The morph function lets you convolve the image with a kernel. It's
decently fast right now. But, in the future we'll have to optimize it by
a lot (unrolling loops, using SIMD instructions, etc.).

Anyway, along with morph I added an edge detection test script showing
how you can use a high pass filter on an image to get all the edges in
it. This is not as good as canny edge dection... but, it's about the
same and fast enough.

We'll need a Hough Transform system in the future to make edge dection
useful. Not sure how that will be implemented... so, that's going to be
far away for now.
2016-02-29 18:04:45 -05:00
iabdalkader
2e7ded5dd4 Add GIF module 2016-02-28 21:34:47 +02:00
iabdalkader
5860695f5d Move helper functions to new files. 2016-02-22 18:41:50 +02:00
Kwabena W. Agyeman
ccd6078c04 Add BMP and P2/3/5/6 file format support.
Added BMP file format reading and writing support code and modified the
ppm code to match. Upper level glue code has been left intact to be
altered in future commits.

Tested save() and ppm writing functionality still works. More
comprehensive tests coming soon.

... Kinda concerend that standard image file formats might not cut it for
the speed we'd like to have when using image files in function calls. I
think only grayscale is going to be fast. All other formats require a
lot of prep work.

I think I may modify some of this low level stuff in the future to
autodetect if an entire grayscale image can be read in or written out
in one go to speed that stuff up.
2016-02-21 17:24:32 -05:00
iabdalkader
a4ea3e0e20 Add filter functions
* Filter functions bypass the default line processing in sensor.c, and pre-process lines.
* Processing is done on the fly, i.e. filters are called from after each line is received.
2016-02-20 03:58:40 +02:00
iabdalkader
b7b4153367 Add integral moving window.
* A new integral image implementation that uses a moving window.
* Integral image is computed in steps, each shift computes n new lines.
* This only requires (image_width * (feature_height+1) * 4) bytes.
* Allows Haar detector to run on QVGA, and allows a second squared
  integral image for standard deviation calculations.
2016-02-17 18:43:09 +02:00
iabdalkader
db667c061f Rename fb_stack to fb_alloc and call init0 in main 2016-02-17 05:24:17 +02:00
Kwabena W. Agyeman
024b16d475 Added some helper stuff.
The alloc functions allow you to use the framebuffer as a storage space.
It's very simple but effective. You can alloc which puts some memory on a
stack... and then when you're done you can free which pops the stack.
Pops (frees) must be done in reverse order of pushes (allocs).

In general, functions should call the init code before using the stack.
It could be in a bad state.

Also, I added some wrappers for file system functions to make that stuff
easier. This will be used in the future.
2016-02-16 21:31:35 -05:00
Kwabena W. Agyeman
6699ea4d0e Added RGB LUT.
And modified the rainbow table so that the RGB888 to RGB565 translation
is done using a rounding technique versus hard floor. This is also used
for the RGB565<->RGB888 LUTs.

Additionally, I added a bunch of stuff to the image library to make
working with images easier. I will using these helpers in the future.

Finally, I cleaned up trailing space in the font stuff (pet peeve).
2016-02-15 22:12:25 -05:00
iabdalkader
7fff65dbd2 Add boards dir to Makefile 2016-02-06 19:32:35 +02:00
iabdalkader
726e3a8e21 Add RGB565 to YUV lookup table 2016-02-03 23:45:20 +02:00
iabdalkader
756c5965d4 Add initial OV7725 driver 2016-01-28 12:40:55 +02:00
iabdalkader
47ae5a7669 Add ATWINC1500 driver 2015-09-15 02:41:36 +02:00
iabdalkader
99bedb06b6 Move firmware files to board directories. 2015-08-01 11:16:59 +02:00
iabdalkader
4174eaf029 Generate binaries in firmware dir 2015-07-28 20:33:05 +02:00
iabdalkader
39b40526d3 Update Makefile for MP 1.4.4 2015-07-18 06:58:47 +02:00
iabdalkader
57cccca3f3 Add support for OpenMV2 2015-05-01 04:44:31 +03:00
iabdalkader
fa7ab8f70a Rename lab.c to lab_tab.c 2015-04-29 04:11:37 +03:00
iabdalkader
6231d528d2 Use pydfu.py instead of dfu-util
* Latest libusb broke dfu-util
* See https://github.com/walac/pyusb/issues/94
2015-04-29 04:08:39 +03:00
iabdalkader
6886c7b531 Update top Makefile
* Remove old modules
* Add MP modules
* Update for new MP code
2015-04-29 04:07:29 +03:00
iabdalkader
d48a7ef1e9 Update Makefiles to use DfuSe files. 2014-11-15 04:21:00 +02:00
iabdalkader
f524650881 Add DFU image
* Generate dfu image
2014-11-11 01:33:16 +02:00
iabdalkader
ef9bf26981 Add Eye Detector 2014-10-25 15:33:02 +02:00
iabdalkader
17d3e73f86 Update MP branch 2014-10-01 01:41:38 +02:00
iabdalkader
5f51438029 Add LBP 2014-09-20 02:02:22 +02:00
iabdalkader
8854f0a9d5 Add JPEG encoder 2014-09-17 21:39:19 +02:00
iabdalkader
b8d989be57 Update MP branch 2014-09-10 23:16:37 +02:00
iabdalkader
2f5b82ec77 Update UART code 2014-09-05 18:09:07 +02:00
iabdalkader
5fdd6e09a3 Add font rendering 2014-09-01 23:43:06 +02:00
iabdalkader
22323eb1a3 Remove dead object files 2014-08-29 19:36:49 +02:00
iabdalkader
0aeab28640 Update MP Modules
* Update all modules for new API
* Move modules to built-in
2014-08-26 20:32:43 +02:00
iabdalkader
f1d1aa5c67 Cleanup all Makefiles
* Add verbose option
* Fix link dependencies
2014-08-26 17:17:59 +02:00
iabdalkader
dac7beadc6 Add mutex 2014-08-20 21:10:43 +02:00
iabdalkader
074557265d Add rainbow filter 2014-08-18 10:33:46 +02:00