Commit Graph

1031 Commits

Author SHA1 Message Date
iabdalkader
e4ee55eefb Update firmware version. 2016-07-27 22:18:43 +03:00
iabdalkader
0da4951e62 Fix integral image lookup 2016-07-27 22:00:51 +03:00
iabdalkader
0363fa8758 Add ToF module. 2016-07-27 15:21:33 +03:00
iabdalkader
f7aa217f39 Use scaled DCT. 2016-07-06 21:19:14 +02:00
iabdalkader
9db7b8113c Set JPEG quality based on frame size.
* Use higher quality/subsampling for small resolutions.
2016-07-03 21:33:19 +02:00
iabdalkader
b5486fc2a3 Set JPEG chroma subsampling based on quality. 2016-07-03 21:27:44 +02:00
iabdalkader
9e592d45bf Add JPEG subsampling enum. 2016-07-03 21:27:28 +02:00
iabdalkader
0575314ab3 Make image pool work on arg image without changing FB. 2016-06-20 22:25:25 +02:00
iabdalkader
02088a14e1 Rename set_binning to set_windowing. 2016-06-20 22:24:00 +02:00
iabdalkader
968bfde8f2 Add new smaller resolutions.
* Add 40x30, 64x32 and 64x64
2016-06-19 21:27:09 +02: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
iabdalkader
6adb46e1fa Make copy_to_fb accept (x,y) offset 2016-06-17 00:31:56 +02:00
iabdalkader
2594a1e320 Add py_helper_lookup_offset. 2016-06-17 00:30:02 +02:00
iabdalkader
76e3a77869 Reduce DS search step by one. 2016-06-15 23:41:08 +02:00
iabdalkader
7a977b5568 Reduce step size in DS search.
* Reduce DS step size instead of switching to smaller pattern.
* Makes it slower but more accurate, close to EX search.
2016-06-15 23:33:33 +02:00
iabdalkader
e40c50f739 Add diamond search for fast template matching. 2016-06-15 22:59:17 +02:00
iabdalkader
d9b03641f7 Add copy to framebuffer function and example script. 2016-06-15 21:59:36 +02:00
iabdalkader
86b038df33 Fix typo in Haar. 2016-06-15 21:04:25 +02:00
Kwabena W. Agyeman
15aed91efd Fixed FFT and Phase Correlation!
There were some mistakes, they are fixed now. FFT 1D and 2D work
flawlessly. No problems with that code anymore.

As for phase correlation I need to study how to interpret the output
better. The function generates noisy results once you move the image too
far and I'm not quite sure if I have the code right for detecting
positive and negative displacements.
2016-06-14 00:00:27 -04:00
iabdalkader
2767791aae Add loop step argument to template matching. 2016-06-14 00:14:22 +02:00
iabdalkader
a25e0c162e Make template matching use ROIs. 2016-06-14 00:07:54 +02: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
f0a6892475 Cleanup template matching code. 2016-06-11 02:00:27 +02:00
iabdalkader
8fac08e29e Fix integral_image_sq bug in calculating first row. 2016-06-10 00:14:41 +02:00
iabdalkader
15ba6a4927 Enable binning when resolution is higher VGA. 2016-06-03 23:05:51 +02:00
iabdalkader
ee2995115f Disable auto zoom/scale factors for VGA resolution.
* Disable auto zoom/scale factors for VGA resolution on OV7725.
2016-06-03 23:04:11 +02:00
iabdalkader
440c9dc8bc Implement binning. 2016-06-03 23:01:28 +02:00
iabdalkader
318b67da42 Fix typo. 2016-05-25 03:42:57 +02:00
iabdalkader
39f439cda5 Fix the base priority when doing a soft-reset 2016-05-16 14:26:48 +02:00
iabdalkader
8f35a14ad8 Update USBDBG patch version. 2016-05-16 14:22:59 +02:00
iabdalkader
2e2c563227 Re-implement line filters with Python callbacks. 2016-05-16 14:22:30 +02:00
iabdalkader
5265211cc4 Remove USBDBG FRAME_UPDATE command. 2016-05-16 13:40:09 +02:00
iabdalkader
5d9fbf729c Enable some MP optimizations. 2016-05-16 13:37:27 +02:00
iabdalkader
fea0b45eaa Update MP branch.
* Fix ADC channels.
* Add 427 AF file.
2016-05-12 18:25:06 +02:00
iabdalkader
a865075e85 Fix Makefile dependencies.
* Fixes issue with parallel builds (make -jn)
2016-05-12 14:28:27 +02:00
iabdalkader
959d3e5410 Disable STM-HAL build in MicroPython. 2016-05-12 14:02:45 +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
8e503f4145 Update to MP v1.8 2016-05-09 21:46:41 +02:00
iabdalkader
9a5992c03e Update code for MP v1.8 2016-05-09 21:46:29 +02:00
iabdalkader
2803a8f483 Update MP branch. 2016-05-04 21:37:15 +02:00
iabdalkader
c10fc56f44 MLX fixes.
* Alloc variables using xalloc.
* Change ADC resolution to 18 bits.
2016-05-04 21:37:10 +02:00
iabdalkader
e5cde106fb Remove MLX variables from linker script 2016-05-04 20:14:52 +02:00
iabdalkader
2b26d46f1e Fix py_fir memory issues. 2016-05-04 20:14:38 +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
a0d7c69cb7 Remove old CC3K code. 2016-05-02 23:11:11 +02:00
iabdalkader
d8359a99e1 Define MAIN_FW_ADDR. 2016-05-01 15:51:20 +02:00
iabdalkader
c7c3ddce63 Add DAC init in main.c
* Fix issue #121
2016-05-01 15:50:10 +02:00
iabdalkader
260caaa8e7 Fix WINC client.send() zeros data being sent.
* Issue #129
2016-04-30 23:08:23 +02:00
Kwabena W. Agyeman
fc605b0a80 Made histeg work for RGB565.
Added YUV to RGB565 conversion to make this happen.
2016-04-29 23:03:19 -04:00
iabdalkader
6b581af1b1 Add mass erase to make flash. 2016-04-29 20:32:14 +02:00
Ibrahim Abd Elkader
ebb7053040 Merge pull request #132 from kwagyeman/master
Add missing cam functionality
2016-04-28 23:58:27 +02:00
iabdalkader
0d5aaf5064 Fix USB descriptors.
* This fix makes the bootloader+fw image enumerate correctly on Linux and Windows.
2016-04-28 12:47:21 +02:00
Kwabena W. Agyeman
80cb701d3b Add missing cam functionality
Added the ability to turn AGC off. Kinda will need the ability to restore
AGC settings back to user specified ones in the future... but, this will
do for now.

Added the ability to turn AEC off. Objectively this function probably
won't be used. But, in low light situations it can help.

Added get_fb() to allow you to get the last image snapshot returned.

There was some old exposure function in the code that was getting
optimized out. So, I deleted the used methods that didn't have any code
in them and commented out the only method that did.
2016-04-27 21:53:06 -04:00
iabdalkader
794bb367ae Fix Bootloader CDC descriptors.
* Removed some unused descriptors, but mainly set the CDC interface number to (1)
  same as MP, as Windows doesn't like different interface numbers for the same device.
2016-04-27 19:38:44 +02:00
iabdalkader
8cd6fbf301 Replace pyboard and MP string descriptors. 2016-04-27 18:17:42 +02:00
iabdalkader
130fcbf162 Pass wValue to control requests. 2016-04-27 08:34:20 +02:00
iabdalkader
cadb73eb5e Fix Makefile build order. 2016-04-26 22:58:07 +02:00
Kwabena W. Agyeman
7a01a9bede Final Imlib Cleanup
Finished going through imlib.c.
-> Histeq uses fb_alloc now and has hook for RGB histeq when reserve YUV
LUT is added (coming soon in next PR).

Cleanuped py_helper.c/h
-> No functional changes. Just added some header info.

Finished going through py_image.c
* 1 - Finished general code cleanup and updating everything to using new
library functions. In particular, I updated the remaining find_*
functions with the new roi clipping code when they accept rois.
* 2 - Made blob stuff return a list when nothing is found so you don't
have to do an if on the returned value anymore.
* 3 - img subscr is more powerful now allowing image reading and
writing. I updated this because I had to use it to find a previous bug
with socket.send() for the WINC driver.
* 4 - Renamed find_eyes to find_eye. Because it just finds one eye.
* 5 - Other than that just general code cleanup to make functions look
consistent.

And yes, changes have been test. Face tracking, eye tracking, keypoints,
etc. all work still.

Future things todo before release:
1 - Change all LAB stuff to YUV.
2 - Add in reverse YUV->RGB LUT and update functions like Mode() to use
this so they don't generate messed up outputs, also histeq() too.
3 - Add any remaining sensor control functions like agc control.
2016-04-25 21:55:49 -04:00
Ibrahim Abd Elkader
3ac7872188 Merge pull request #130 from kwagyeman/master
Improve JPEG capabilities.
2016-04-26 02:47:08 +02:00
iabdalkader
232461295d Remove old DFU code. 2016-04-25 20:35:36 +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
iabdalkader
508f303d91 Move ISR vector start of the main firmware image. 2016-04-25 18:19:39 +02:00
iabdalkader
d14c55251d Change interrupt vector table offset.
* Set to 0x08010000 where the main FW image starts
2016-04-25 18:18:27 +02:00
iabdalkader
9ed107ccee Re-enable IRQs in main.c 2016-04-25 18:18:03 +02:00
iabdalkader
87740c0170 Add CDC bootloader source dir 2016-04-25 18:17:21 +02:00
Kwabena W. Agyeman
367e5fdd3d Improved JPEG capabilities.
* Added the ability to control the quality on JPEG functions... However,
due to our JPEG implementation this doesn't seem to help. 90% JPEG
quality images and regular images should be about equal. But, you can
see heavy degredation with 90% still. E.g. text is unreabable. Not
exactly sure why this is happening but it can be fixed later.

* Changed the compress() function to compressed(). Also, it now
compresses using FB_Alloc to prevent realloc issues when compressing.

* Added new compress() function. This function compresses an image in
place and if that image is the frame bufffer then it will update the
frame buffer bpp value to reflect the image was compressed. Users can use
this function to basically finalize the frame buffer and then pass the FB
to functions that need to send image bytes. The benefit of using this
function is that it should allow higher quality JPEGs and let everything
run at a faster speed while connected to the IDE.

I made this function to speed up WiFi. However, I encountered a bug with
the winc.send() method. It appears to zero the bytes it sends. I didn't
debug further except to verify that the image data became zero after
calling send.
2016-04-23 16:37:21 -04:00
Kwabena W. Agyeman
bb9d79d744 Fixed dilate.
This was bugged. Tested and now works.
2016-04-21 13:11:38 -04:00
iabdalkader
da612ff75f Apply HAL I2C/DMA patch from MicroPython. 2016-04-20 23:03:39 +02:00
iabdalkader
ef772db6c4 Up MP branch 2016-04-20 22:30:43 +02:00
Kwabena W. Agyeman
b534dc6ffc Imlib cleanup
*Changed subimg to copy.
*Made blend work the same way as all our other double image argument
functions.
*Changed bilt to replace (the name of bilt is way to esoteric). Replace
gives you the basic assignment op.
* Removed scale/sacled. I removed this code because we don't want to
encourage people to scale things and allocate additional images in
memory. I decided to keep copy() for completeness sakes... but, I don't
see anyone using it. (By completeness sakes I mean that we now have the
assignment op, copy op, etc. for an image object).
* Removed rainbow. This feature is built into the FIR module now.

Moving on, compress needs to be renamed to compressed and a new compress
function will need to be added.

The compress() function will compress the image (or frame buffer, etc)
and not return a new object. The compressed() function will return a new
object and not compress the original image.

The compress function will make it easier for users to compress images
once they are done working on them before sending the image some where.
I don't see compressed() being used much then after adding the
compress() function. Since the compress() function won't use up heap
space this makes it very good.
2016-04-19 21:42:56 -04:00
Kwabena W. Agyeman
8a2852b706 Fixed file buffer bug.
This wasn't getting reinited breaking the system.
2016-04-14 23:56:54 -04:00
Kwabena W. Agyeman
1b9be6f81c Fixed blob merge bug.
Merging now keeps trying after a merge to make sure it's collected
everything.
2016-04-13 23:48:16 -04:00
Kwabena W. Agyeman
16daeb83a2 Fixed blob code.
Removed micropython code from the image libary. Also, blobs are now 10
tuple values by default now. The multilist thing has been removed from
blobs and it will return just a list of blobs instead of a tree of
lists.

Filter functions still work too.
2016-04-13 23:16:51 -04:00
Kwabena W. Agyeman
9e5d379c18 Remove old code.
Pixels, centroid, and orientation are calculated in the blob code now.
As for threshold, it is no longer needed (plus, it required storing a
secondary image in RAM which isn't really something we can handle).
2016-04-09 19:32:14 -04:00
Kwabena W. Agyeman
d1ff36602a New blob code.
Blob tracking has now been updated to work without requiring prior
segmentation of the image. You can still run it on a segmented image,
but, that is not needed anymore.

Use the copy color feature of the OpenMV IDE to get a color in the
image. Once you have that you can then pass the color to find_blobs which
will output a tuple of lists of blobs for each color. By default, all
blobs less than 1/1000th of the image are filtered out, however, you can
add a custom filter function which gets the image and the blob about to
be added to the list and you can decide to filter it or not.

For marker tracking, we now have a function called find markers which
basically merges all the blobs found by find blobs into one list of
blobs. Each new blob will have a color code value which will tell you
what colors are part of that blob. We support tracking up to 30 unique
colors this way.
2016-04-09 11:43:35 -04:00
iabdalkader
37c8587333 Fix WINC's FW update.
* Remove unused WINC code.
* Replace WINC fw update process with a single fw image.
2016-04-06 02:35:32 +02:00
iabdalkader
f841828818 Add WINC fw dump function. 2016-04-06 02:30:42 +02:00
iabdalkader
cc67372726 Add fw_dump 2016-04-06 02:29:39 +02:00
iabdalkader
6aaef6b68d Update WINC's firmware image. 2016-04-06 02:28:18 +02:00
iabdalkader
f2a1a1f641 Fix printf format. 2016-04-05 23:42:37 +02:00
iabdalkader
6addddbbc7 Fix WINC's firmware_verify. 2016-04-05 23:40:09 +02:00
Ibrahim Abd Elkader
749cd96e0c Merge pull request #112 from kwagyeman/master
Add mean, median, and mode filters.
2016-04-05 23:22:23 +02:00
iabdalkader
b9ec840a76 Add winc fw_update function. 2016-04-05 22:35:02 +02:00
iabdalkader
3268edceb2 Add WINC1500 Firmware image and certificates.
* FW version 19.4.4
2016-04-05 22:32:50 +02:00
iabdalkader
330b41aab6 Add WINC1500 FW upload code. 2016-04-05 22:31:39 +02:00
iabdalkader
dae73f6250 Update WINC1500 driver to 19.4.4 2016-04-05 22:30:00 +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
1566b38bde Implement fw_version. 2016-04-02 01:39:53 +02:00
iabdalkader
27adf0dcd2 Enable CONF_MGMT. 2016-04-02 01:39:29 +02:00
iabdalkader
0d19f693c0 Implement Listen and Accept. 2016-03-31 22:35:49 +02:00
iabdalkader
e5fd02c59a Implement bind, sendto and recvfrom. 2016-03-31 02:46:14 +02:00
iabdalkader
4201f0480d Use fd instead of u_state. 2016-03-31 01:05:26 +02:00
iabdalkader
a5d1b0f446 Implement socket settimeout 2016-03-31 01:04:57 +02:00
iabdalkader
1cccae0fcb Implement WINC send/recv. 2016-03-30 18:51:13 +02:00
iabdalkader
bf674dbe6d Add Socket and DNS callbacks. 2016-03-30 01:47:35 +02:00
Kwabena W. Agyeman
bc687ebf59 We seem to be doing this alot in the code.
So I'm just adding a function to do it cleanly and efficently. Call
skip_frames() after changing any camera settings to let it settle.

10 frames by default works fine. Tested it.
2016-03-28 22:59:59 -04:00
iabdalkader
4e31f25db8 Additional qstr definitions for OpenMV. 2016-03-29 02:26:39 +02:00
iabdalkader
9003a27c85 Rename fir.display to fir.draw 2016-03-27 00:42:54 +02:00
Kwabena W. Agyeman
a6c2efcebe Renamed Display to Draw
And fixed type in blend. Per Ibrahim's suggestion.
2016-03-26 10:26:19 -04:00
iabdalkader
5411f9e8e7 Update MP branch. 2016-03-26 15:15:07 +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
iabdalkader
f447455580 Disable WINC's debugging info. 2016-03-26 00:15:28 +02:00
iabdalkader
ce949333f2 Rename WINC1500 Sockets.
* Rename functions in WINC's sockets implementation to avoid
conflicts with other sockets implementations.
2016-03-26 00:14:01 +02:00
iabdalkader
9dd3dce5af Update MP branch 2016-03-26 00:11:52 +02:00
Kwabena W. Agyeman
2fa8227c7b Add AWB/HMirror/VFlip
Added setters for these camera settings. AWB is necessary for color
tracking to work correctly. AGC still runs, which causes lighting
shifts. It may need to be disabled too. Not sure... if I want to do that
or not however, because without it lightning won't get normalized to
remain at a certain level. So, turning AGC off may cause issues in other
ways.
2016-03-25 16:36:10 -04:00
Kwabena W. Agyeman
a74dd50eaf Improved IR code.
Return min and max from read_ir now. Also, made drawing functions take
IR values.

Example scripts have been updated to work with the new module code.
2016-03-24 19:52:00 -04:00
iabdalkader
dfad6e4c0a Update MP branch. 2016-03-25 00:37:27 +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
Ibrahim Abd Elkader
825911abe6 Merge pull request #99 from kwagyeman/master
Move LCD code into module.
2016-03-19 01:33:35 +02:00
iabdalkader
44895ead25 Add LCD module 2016-03-19 01:32:05 +02: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
iabdalkader
900b5cdba2 Add P6 pin alias. 2016-03-15 00:11:13 +02:00
iabdalkader
9a8a5375da Add pin aliases. 2016-03-15 00:03:02 +02:00
iabdalkader
d4ea452902 Fix median code.
* Use new IM_ macros.
* Fix allocation problems.
2016-03-13 23:37:58 +02:00
iabdalkader
33d4d2a1ad Support keypoints on QVGA resolution.
* Use the moving window integral to compute keypoints.
2016-03-13 01:44:07 +02:00
iabdalkader
2f9a541cbc Abort DMA transfer after snapshot. 2016-03-11 04:17:18 +02:00
iabdalkader
ebf13197a9 Disable USB IRQ before stopping script.
* This ensures that FS IRQ will never run during a soft-reset which
causes issues when using SD card.
2016-03-11 04:14:19 +02:00
iabdalkader
31697a163b Re-init storage after soft-reset. 2016-03-11 04:13:23 +02:00
iabdalkader
0370eb54be Move SD card initialization to sdcard_init 2016-03-11 04:12:06 +02:00
Kwabena W. Agyeman
302deb0662 Add file read speed.
File reading is runing ultra fast now. We're getting that SD card speed
the STM32 promised now. The file buffer commands have been updated to
alloc as much available memory to read as much of a file in as possible
now to speed up things. This works really great.

Note however, while the file buffer is active you have to use the file
buffer versions of tell and size. Spent a few hours on tracking down an
error related to not using the buffered versions.
2016-03-08 23:38:13 -05:00
Kwabena W. Agyeman
14dbcbd73c Updated code to use fb_alloc.
All file write functions now use fb_alloc to go much faster. Writes are
re-directed to the extra frame buffer RAM and are grouped until they can
be written in a massive multi-block write to the SD card. We get the
best SD card write speed by doing things this way.

Ideally we'd want to buffer the whole file... but, this is about as good
as we're going to get for now.

Going to fix reading functions to use the same buffer next.
2016-03-07 00:09:04 -05:00
iabdalkader
2ab0688cbd Fix comment.
* Framebuffer is not actually global.
2016-03-06 19:03:30 +02:00
iabdalkader
6cb7288def Add NORETURN to __fatal_error 2016-03-06 19:03:00 +02:00
iabdalkader
a1c9e8a6f6 Set fb values directly when request frame size. 2016-03-06 19:02:12 +02:00
iabdalkader
d1e782df3d Remove default sensor config.
* Not really needed.
2016-03-06 19:01:10 +02:00
iabdalkader
e3cc4cd83f Add delays after changing pixformat/framesize. 2016-03-06 19:00:41 +02:00
iabdalkader
3e6e84cbb4 Skip the first frame after changing size or format. 2016-03-06 18:38:25 +02:00
Kwabena W. Agyeman
66248c444b Update Gif to use fb_alloc_all.
And tested it along with mjpeg to make sure all this stuff is good. I
also see the issue with QQVGA now. That just appeared.
2016-03-05 22:29:21 -05:00
iabdalkader
b78e325c60 Up MP branch. 2016-03-06 03:14:42 +02: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
iabdalkader
acc35704d8 Disable IRQs when doing a soft-reset. 2016-03-06 02:51:34 +02:00
iabdalkader
2ab317063d Re-exec REPL if there's no script to execute. 2016-03-06 02:39:58 +02:00
iabdalkader
fe506fa0fb Use sizeof(tx_buf_len) instead of length.
* Length should always be 4 but it's safer this way.
2016-03-06 02:37:36 +02:00
iabdalkader
c12473d8b7 Execute a script only if there's no script running. 2016-03-06 02:36:45 +02:00
iabdalkader
28047269ac Add DSB after setting USBDBG IRQ. 2016-03-06 02:36:10 +02:00
iabdalkader
87f9c92f1b Skip the first JPEG/RAW frame.
* Set BPP to zero in set_pixformat to skip compressing/sending the first frame.
2016-03-06 02:32:11 +02:00
iabdalkader
911f9827ea Enable DMA IRQ just before the snapshot. 2016-03-06 02:28:05 +02:00
Kwabena W. Agyeman
98800c31c7 Add fb_alloc_all.
Now you can just grab all the free ram in the frame buffer in one go.
This fixes problems figuring out how many lines to alloc. Will update line
op code with this new info later.
2016-03-05 11:27:37 -05:00
iabdalkader
06b1cfca3b Use IRQ priorities defined in irqs.h 2016-03-05 18:25:51 +02:00
iabdalkader
55a4b4536f Add irqs.h.
* Defines IRQ priorities and functions.
2016-03-05 18:23:53 +02:00
iabdalkader
5dcedb8397 Align GIF buffers.
* Make GIF buffers aligned so DMA can be used.
2016-03-05 16:23:43 +02:00
iabdalkader
9230f0d53e Use DMA for SDIO transfers 2016-03-05 15:44:39 +02:00
Kwabena W. Agyeman
9325029675 Add support for color gif.
Color gifs look very good for how bad you'd expect them to be with just
7 bits of color (rgb232) - quite amazing. Also, I  hardened the gif
module to make it "user ready".
2016-03-04 23:30:01 -05:00
iabdalkader
03a06a409d Added color conversion strings. 2016-03-04 15:36:39 +02:00
Kwabena W. Agyeman
0ded05e333 Add color functions.
Now you can convert from rgb to lab/grayscale and vice-versa. Without
this functionality it would be hard to deal with moving between RGB and
LAB.
2016-03-03 23:48:04 -05:00
iabdalkader
02ef98f25f Move MSC bot data to main SRAM (update MP). 2016-03-04 00:59:06 +02:00
iabdalkader
af82c9936d Move MSC bot data to main SRAM.
* MSC can use DMA transfers.
* Free about 2KBs of CCM.
2016-03-03 15:37:13 +02:00
iabdalkader
872b7c1c5e Update qstrs. 2016-03-03 01:14:03 +02: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
iabdalkader
3e5bfb27cc Move FatFS file buffer to main SRAM.
* Allows DMA transfers of file data.
2016-03-02 00:19:29 +02:00
iabdalkader
3ea5761076 Add _fb_alloc linker script variable. 2016-03-01 23:47:13 +02:00
Kwabena W. Agyeman
6ed08213b5 Fix unintialized error.
If the rect was not intersecting these functions would have returned bad
values.
2016-02-29 21:31:59 -05:00
iabdalkader
744329f8f6 Add strings for morph. 2016-03-01 01:42:51 +02:00
iabdalkader
e0c93b8ec3 Add missing morph qstrs 2016-03-01 01:26:03 +02: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
Kwabena W. Agyeman
fb8b357c24 Dilate and errode working.
The old code did not actually implement the errode anhd dilate kernels
correctly. However, it migh have been a little faster because it avoided
the boundary problem.

In the future we can optimize all the kernel code to have different loops
for doing the edges of image versus the center. But, for now, this is
good enough. QVGA color tracking with kernels will be slow, but, the
speed can be improved with QQVGA resolution. Using a 3x3 kernel is
plenty fast. Larger ones are slower.

I also added the ability for you to set the threshold for erode and
dialte. This lets you make the kenrel a little bit smarter so that it
won't errode or dilate a pixel unless the threshold is met. Meaning,
you'll be able to use erode to erode an image down to 1 pixel wide
lines.
2016-02-28 16:27:49 -05:00
iabdalkader
d4e1e3d323 Alloc FatFS LFN buffer on stack.
* Saves 512 bytes
2016-02-28 21:54:30 +02:00
iabdalkader
2e7ded5dd4 Add GIF module 2016-02-28 21:34:47 +02:00
iabdalkader
963dd69ca0 Fix typo. 2016-02-28 08:06:32 +02:00
iabdalkader
afa1686940 USE OMV_XCLK_FREQUENCY from OMV board config file. 2016-02-28 04:30:37 +02:00
iabdalkader
8b3b7e6ece Fix skin filter.
* Remove Y from GS threshold.
* Not really fixed, just looks slightly better.
2016-02-28 04:10:56 +02:00
iabdalkader
7e1a4169a7 Add match_descriptor function.
* A single function to match LBP/FREAK descriptors.
2016-02-28 03:39:13 +02:00
iabdalkader
154cb5be69 Change descriptor functions to accept file pointer. 2016-02-28 03:22:07 +02:00
iabdalkader
acafef5207 Revert HaarCascade.
* HaarCascade doesn't really fit into generic descriptor functions.
2016-02-28 02:37:35 +02:00
iabdalkader
67acf7188c Use one load/save function for all descriptors. 2016-02-28 01:38:24 +02:00
Kwabena W. Agyeman
4ed49082a1 Background Subtraction is working!!!
Woot, all the effort to make it so you can manipulate the image buffer
with an image off disk works!

Try out the motion_detection script.
2016-02-27 11:58:37 -05:00
Kwabena W. Agyeman
00ee215e89 Add line op function.
All the work previously has been more or less leading up to supporting
this function. The line op function will open a file and execute a
function pointer on each line of the file opened to modify the frame
buffer.
2016-02-27 09:59:54 -05:00
Kwabena W. Agyeman
1121a6f7df Fixed save image.
It now figures out the file type from the file extension. If no file
extension is given it just saves the file as BMP if its not a JPEG image
or JPEG if it's a JPEG image. If you specify an extension and the file is
not of that type then it will give you an error.

The new test_save.py should run until you reach the JPEG image part
where it quits due to lack of JPEG support natively on OV7725 boards.
Maybe JPEG mode should be supoorted by just compressing pictures?
2016-02-26 22:00:04 -05:00
iabdalkader
2b27d1542f Add save LBP descriptor. 2016-02-26 23:12:15 +02:00
Kwabena W. Agyeman
ac3d1e4373 Add BMP/PNM/JPEG image file loading and saving.
There's not a lot of actual functionality changes from the last commit.
However, switching the basic wrapper library to just long_jump on
failure and moving all the state info to structs required changes to all
the base functions in the last commit. The rest of the changes are to
link in the new functionality and to get the code to compile (usbdbg.c
edits).

Next I'll work on a function which abstracts the problem of opening an
image up and executing a line by line function op on it. I already
worked the code out for that. But, it's not in this commit to keep
things streamlined.
2016-02-25 22:26:56 -05:00
iabdalkader
6d1044ffcf Up the max size of integral images to QVGA.
* With the new integral moving window we can support face detection,
  keypoints and template matching on QVGA frames. However, it was only
  implemented and tested for face detection.

* Increasing the max integral frame now for easier testing.
2016-02-26 03:27:24 +02:00
iabdalkader
c43906eb3d Fix FREAK's mean_intensity function.
* Using imlib_integral_lookup for lookups.
* Rounding errors caused the patch not be rectangular.
2016-02-26 01:47:22 +02:00
iabdalkader
074cf9d5e4 Add pointer to matching keypoint to kp_t struct.
* This way we don't need to allocate the array of matching keypoints
and risk running out of memory due to fragmentation. So all or nothing.
2016-02-26 01:44:23 +02:00
iabdalkader
1b27383c9d Allocate kpts until GC is almost out of memory
* Keep allocating keypoints until GC is out of memory.
2016-02-26 00:50:46 +02:00
iabdalkader
5ff5419bf1 Return empty list if no blobs were found.
* Fixes #81
2016-02-26 00:47:31 +02:00
iabdalkader
3e4c2c2f3b Fix keypoint bug.
* Set keypoint descriptor to zero, bug was introduced when switching to arrays.
2016-02-26 00:26:37 +02:00
iabdalkader
b15c0c6bc0 Fix formatting. 2016-02-26 00:26:20 +02:00
iabdalkader
5c6056f875 Add file format strings 2016-02-25 11:52:10 +02:00
Kwabena W. Agyeman
d8ac8f9408 Fix swap bug.
The code clearly did not swap mins and maxes.
2016-02-24 19:07:57 -05:00
iabdalkader
f34a7e30d7 Use fb_alloc to allocate corners.
* Leaves more heap memory for keypoints.
2016-02-24 06:30:14 +02:00
Kwabena W. Agyeman
4df0b5044b Add top level file open function.
Fimrware will now automatically detect the appropriate file type and read
in that file type correctly.

Working on tying on of this stuff togheter next. It's getting a little
bit too complicated to deal with error cases. Need to add error message
function layer.
2016-02-23 21:26:43 -05:00
iabdalkader
c3936f4322 Fix FAST/FREAK ROI. 2016-02-24 00:38:48 +02:00
iabdalkader
4d7db778fb Remove angle from keypoint.
* Not really used right now and saves 4 bytes per keypoint.
2016-02-23 20:43:33 +02:00
iabdalkader
3a747ef952 Use arrays in FAST/FREAK keypoints.
* Using arrays for FAST/FREAK keypoints, this saves some memory
allocated for intermediate data.
2016-02-23 18:19:49 +02:00
iabdalkader
7a22cb3e5c Extract keypoints in one step.
* Make find_keypoints extract FAST keypoints.
2016-02-23 00:55:54 +02:00
iabdalkader
93d3885a3c Set keypoints threshold range between 0 and 100. 2016-02-22 20:31:24 +02:00
iabdalkader
9d02e2a42a Make match_lbp accept roi and extract second LBP. 2016-02-22 19:41:16 +02:00
iabdalkader
473b8025bf Fix assertion in find_features. 2016-02-22 19:39:26 +02:00
iabdalkader
015181588a Fix assertion in find_features. 2016-02-22 19:35:11 +02:00
iabdalkader
ddcb170af0 Cleanup py_image.c
* Code cleanups in py_image.c
2016-02-22 19:17:14 +02:00
iabdalkader
124a31772c Rename helper functions. 2016-02-22 18:47:35 +02:00
iabdalkader
5860695f5d Move helper functions to new files. 2016-02-22 18:41:50 +02:00
iabdalkader
0f48c12a89 Replace all mp_map_lookup()s with helper functions. 2016-02-22 18:35:00 +02:00
iabdalkader
4bcdb251a3 Update MP branch 2016-02-22 18:02:59 +02:00
iabdalkader
93dc73c7f2 Fix arg to get_rectangle_kw. 2016-02-22 18:00:20 +02:00
iabdalkader
4c63721efa Use default roi when calling save_image 2016-02-22 17:55:26 +02:00
Kwabena W. Agyeman
901716b878 Made grayscale read/writing fast.
RGB565 reading and writing is going to be slow. But, grayscale is going
to be going as fast as the system can go.

If Omnivision has just reversed the byte order of data sent to the
camera we wouldn't have this problem for RGB565.
2016-02-21 21:24:57 -05:00
iabdalkader
4e5b200bdf Make keypoints_match return the % of matching kpts.
* Change keypoints_match to return the percentage of matching keypoints.
2016-02-22 03:31:15 +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
43dc87d43e Fix HQVGA resolution. 2016-02-21 23:05:07 +02:00
iabdalkader
032a6e3e4d Make Haar detector work on ROIs. 2016-02-21 23:01:34 +02:00
iabdalkader
1d4b95353a Fix Iris bounding box. 2016-02-21 22:39:14 +02:00
iabdalkader
50e53c91bc Change Iris detector to work on a single region.
* This allows the detector to work on ROIs detected by the eye Haar
  cascade, which improves the accuracy and speed of the detection.
2016-02-21 20:38:01 +02:00
iabdalkader
e18058f27c Update MP branch.
* Add new qstrs.
2016-02-21 03:46:17 +02:00
Kwabena W. Agyeman
c3cfb117d0 Add frame differencing functions.
The negate function gives you the ability to negate an image before
running difference on it. The difference function will subtract two images
from each other and return the abs() of the result.

I believe it would have been optimal to work on the RGB565 image in the
LAB color space. However, since we don't have an inverse LAB lut this is
not possible. If we could replace LAB with YUV then that would free up
space to have an inverse YUV table (YUV->RGB).
2016-02-20 20:29:19 -05:00
Kwabena W. Agyeman
140ceb3b77 Fixed bug in centroid and added tests.
Stuff works. Yay! Moving on to other things now.
2016-02-20 16:04:59 -05:00
Kwabena W. Agyeman
88d9c02a1b Draw keypoints now accepts lists.
Made draw keypoints accept lists of (x, y, angle) tuples. I did this so
it could be used to show object rotation easily.
2016-02-20 16:04:59 -05:00
iabdalkader
767b0d99b9 Update MicroPython branch 2016-02-20 20:12:02 +02:00
Kwabena W. Agyeman
0606f5be44 Added binary image functions.
Pixels, centroid, orientation, along with the basic binary tool kit
functions like and/or/xor.
2016-02-20 11:46:26 -05:00
iabdalkader
db5464948b Use fb_alloc in dilate, erode and median. 2016-02-20 17:48:42 +02:00
iabdalkader
f3e85e1dbb Add fb_free_all.
* Free all blocks allocated on fb ram
2016-02-20 17:41:21 +02:00
iabdalkader
84ff228384 Fix RGB skin filter 2016-02-20 06:16:22 +02:00
Ibrahim Abd Elkader
e72e55802c Merge pull request #73 from kwagyeman/master
Fix set pixel.
2016-02-20 06:03:48 +02:00
Kwabena W. Agyeman
b01adfee26 Fixed up drawing code and scripts along with drawing code.
Set pixel works too now.
2016-02-19 22:55:50 -05:00
iabdalkader
015f924096 Fix BW filter to handle RGB. 2016-02-20 04:22:03 +02:00
Kwabena W. Agyeman
a035aae493 Fixed set pixel. 2016-02-19 21:05:02 -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
a40101e3e0 Fix indent. 2016-02-20 01:26:18 +02:00
iabdalkader
8d47b7b9b2 Add helper functions to lookup color and int. 2016-02-20 01:24:29 +02:00
iabdalkader
e31e504f64 Update MP branch 2016-02-19 17:02:45 +02:00
Kwabena W. Agyeman
bcd5151412 New drawing functions.
All the drawing functions have been updated to handle automatic clipping
when drawing offscren and work with both grayscale and RGB565.
Additionally, all functions now accept color arguments.

I've also updated the example scripts with the new functions and tested
them out to make sure they work.

Additionally, I wrote a test suite for the drawing functions to make
sure they work.
2016-02-18 22:40:12 -05:00
iabdalkader
04a2e89fd5 Optimize JPEG stack usage 2016-02-18 17:55:45 +02:00
Kwabena W. Agyeman
f9ae24f3a0 Reverted commands back to old argument format. 2016-02-17 23:50:08 -05:00
Kwabena W. Agyeman
dd6a322646 Added basic image querying functions.
Now you can get the width/height/format along with size. Additionally, I
fixed up get and set pixel.
2016-02-17 23:04:23 -05:00
iabdalkader
5aa3555a36 Add enable/disable JPEG to USB commands. 2016-02-18 04:12:53 +02:00
iabdalkader
da15b6a915 * Allow fb compression to be enabled/disabled.
* This allows reading RGB images on PC if needed.
2016-02-18 04:01:41 +02:00
iabdalkader
8fd89db5fe Add Hardware/Software JPEG flags to sensor flags.
* Not used right now.
2016-02-18 03:26:41 +02:00
iabdalkader
31679cab9a Allow Haar detector to accept ROIs. 2016-02-17 22:36:57 +02:00
iabdalkader
61f98e6c21 Cleanup old integral image code. 2016-02-17 20:34:21 +02:00
iabdalkader
dc86780578 Use FB_PIXELS() to get a pointer to fb pixels. 2016-02-17 20:32:50 +02:00
iabdalkader
6460fefa15 Fix old integral image lookup 2016-02-17 20:32:33 +02:00
iabdalkader
d658608061 Fix FB_PIXELS() macro.
* If bpp > 2 (means JPEG image) return pixels + bpp (bpp stores image size in JPEG mode)
* If bpp <= 2 (means GS or RGB image) return pixels + w * h * bpp.
2016-02-17 20:27:58 +02:00
iabdalkader
d2ac2c63a8 Use fb_alloc to alloc/free integral images. 2016-02-17 20:06:31 +02:00
iabdalkader
c2e6d96c27 Remove unused xalloc include 2016-02-17 20:01:05 +02:00
iabdalkader
d3d7e5dc39 Use typdef's for sensor enum and structs. 2016-02-17 19:46:45 +02:00
iabdalkader
d639df0bfe Cleanup sensor.h comments. 2016-02-17 19:08:56 +02:00
iabdalkader
c809ec1b53 Add comment about cropping. 2016-02-17 18:49:51 +02:00
iabdalkader
33e552b276 Add DMA2D to sthal's Makefile 2016-02-17 18:48:20 +02:00
iabdalkader
5fdaf08cac Increase heap size by 256 bytes. 2016-02-17 18:47:33 +02:00
iabdalkader
c1bf4ad33d Add one pass standard deviation function. 2016-02-17 18:46:46 +02:00
iabdalkader
027641e51e Improved Haar detector.
* Use a scanning factor proportional to the current scale.
* Use the new integral moving window to allow two integral images
  (sum and sum squared) for fast mean, variance and standard deviation.
* Higher FPS and more accurate detection.
2016-02-17 18:43:47 +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
c043ebc233 Update qstrs 2016-02-17 18:16:15 +02:00
iabdalkader
0904f0bb6b Fix FB_PIXELS()
* Return fb->pixels+fb->bpp when JPEG is enabled.
2016-02-17 05:28:28 +02:00
iabdalkader
db667c061f Rename fb_stack to fb_alloc and call init0 in main 2016-02-17 05:24:17 +02:00
Ibrahim Abd Elkader
cfa9b6e440 Merge pull request #67 from kwagyeman/master
Add framebuffer alloc functions.
2016-02-17 05:07:34 +02:00