Commit Graph

804 Commits

Author SHA1 Message Date
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