Commit Graph

335 Commits

Author SHA1 Message Date
Kwabena W. Agyeman
ca94ffec42 Avoid using roundf
While this shouldn't happen the method seems to sometimes round up past
limits. For example, 1 * 2.0 could be 3 because the 2.0 might be like
2.0000000000001.

So, avoid using roundf. There are other methods this needs to be
switched out on. But, will do these ones for now.

Note that not all roundf values must be removed... just areas where
there's a clear limit on the max value returned from roundf.
2019-02-16 21:19:05 -05:00
Kwabena W. Agyeman
954431ef52 Add mask functionality to clear. 2019-02-16 21:19:05 -05:00
Kwabena W. Agyeman
1f72c3750d Add back mask methods. 2019-02-16 21:19:05 -05:00
iabdalkader
6f7187526a Fix keypoint op. 2019-02-13 23:09:47 +02:00
Kwabena W. Agyeman
f615b0a607 Fix bugs in copy(). 2019-02-06 02:15:39 -05:00
Kwabena W. Agyeman
1259bcaa71 Make to_x() methods smarter about the frame buffer. 2019-02-06 02:15:39 -05:00
Kwabena W. Agyeman
bb9b78f4fe Improve copy_to_fb for load_image. 2019-02-02 23:21:05 -05:00
Kwabena W. Agyeman
b8df7033ab Improve Image() so you can now create null images. 2019-02-02 23:21:05 -05:00
Kwabena W. Agyeman
6ca963a7eb Fix in-place cap. 2019-02-02 23:21:05 -05:00
Kwabena W. Agyeman
67686c5f1b Update old image handles during in-place actions. 2019-02-02 23:21:05 -05:00
iabdalkader
7604983fca Use stdint in color conversion functions. 2019-01-30 00:27:40 +02:00
Kwabena W. Agyeman
6d59e59321 Upgrade copy()
* Copy is really good now.
* Added crop/scale which are variants of copy.
2019-01-28 00:13:17 -05:00
Kwabena W. Agyeman
1518e678ba Fix wrong size calculation. 2019-01-27 19:57:52 -05:00
Kwabena W. Agyeman
27fceecc05 Fix wrong bit depth. 2019-01-27 19:42:15 -05:00
Kwabena W. Agyeman
7f929f5ca6 Add color channel extraction per forum users request. 2019-01-27 19:25:21 -05:00
Kwabena W. Agyeman
949f738073 Modernize pooling methods. 2019-01-27 18:38:50 -05:00
Kwabena W. Agyeman
9edded29da Export color conversion functions to Python. 2019-01-27 22:42:38 +02:00
Kwabena W. Agyeman
3a8ac88f66 Update blob code and examples. 2019-01-27 00:46:15 +02:00
Kwabena W. Agyeman
ac4afe0d24 Fixed binary to work correctly
* It now actually parses a list of thresholds and not just the first.
* to_bitmap/copy work as they should in-place now.
2019-01-04 02:29:16 -05:00
Kwabena W. Agyeman
0554c189a9 Add back the ability for draw keypoints to handle keypoint tuples.
Can call it without a keypoint object now again.
2019-01-04 00:32:27 -05:00
Kwabena W. Agyeman
e7f7a732eb Add alpha blening support to draw image. 2019-01-02 12:33:15 -05:00
Kwabena W. Agyeman
4ba25713b7 Error check scaling on draw_string. 2019-01-02 12:16:20 -05:00
Kwabena W. Agyeman
262769989f Allow non-integer scaling on draw_string. 2019-01-02 12:13:52 -05:00
Kwabena W. Agyeman
3e05d24ce9 Don't require self if operating on self. 2019-01-02 12:13:01 -05:00
Kwabena W. Agyeman
6b11353312 Add mod support to div. 2019-01-02 11:52:56 -05:00
Kwabena W. Agyeman
dbe7bf0591 Add transpose support to replace and aliases
Now you can rotate and image by 0, 90, 180, 270 degrees along with
vertical flip and horizontal mirror. This method works in place or out
of place.
2019-01-02 01:35:34 -05:00
Kwabena W. Agyeman
35e19f0233 Remove unused marks. 2019-01-01 02:43:55 -05:00
Kwabena W. Agyeman
8bcf5ac0c3 Add gamma correction
A user requested this a while ago. This feature also ads contrast and
brightness correction. The code is fast!
2019-01-01 02:28:40 -05:00
Kwabena W. Agyeman
b47dbe2c15 Kwabena/drawing updates (#422)
* Add ellipse drawing function.
2018-12-31 18:32:13 +02:00
Kwabena W. Agyeman
e97e0a2021 Add MLX support. 2018-09-24 22:58:47 +02:00
Kwabena W. Agyeman
abe97a73ba Disable Mean on OMV2 2018-08-10 16:09:53 +02:00
iabdalkader
4e34b32ec6 Fix OMV2 build.
* Disable morph().
2018-07-30 19:42:47 +02:00
iabdalkader
a69bfc3709 Add imlib flag to enable/disable math ops. 2018-07-14 19:53:54 +02:00
iabdalkader
f598de860a Add selective search. 2018-06-30 18:30:14 +02:00
iabdalkader
14617a0713 ORB: support RGB images. 2018-06-28 18:22:00 +02:00
Kwabena W. Agyeman
157a469ec3 Fix finding small apriltags. 2018-06-20 18:48:25 +02:00
Kwabena W. Agyeman
bd77afbc0a Improved H7 AprilTags res. 2018-06-20 18:42:50 +02:00
iabdalkader
f135c12cd9 Enable mutable images for Haar cascades. 2018-06-19 22:51:45 +02:00
iabdalkader
940c56ec8c Rename py_image_unavailable_obj. 2018-06-04 18:17:21 +02:00
iabdalkader
c9e4be4df3 Move py_image_unavailable_obj to py_helper. 2018-06-04 18:14:28 +02:00
Kwabena W. Agyeman
8a44f0cd91 Support converting binary images to bitmaps in place.
This is useful for building image masks.
2018-06-04 17:26:35 +02:00
iabdalkader
d151f7e38d NN: Remove hard-coded NNs. 2018-05-25 22:50:28 +02:00
iabdalkader
36948fff45 Fix keypoints match list. 2018-05-17 23:55:56 +02:00
Kwabena W. Agyeman
ac2d2fc1cd Update find circles with min and max radius to run faster.
This was a user request.
2018-05-13 19:31:32 -04:00
Kwabena W. Agyeman
76e9d9fd50 Fix compile issues with the M4 firmware.
Also added a method that will give an error to the user versus not
found.
2018-04-14 02:23:17 -04:00
Kwabena W. Agyeman
93b81fcffc Add image conversion methods.
Requested by customers to make a grayscale image and rainbow image.
2018-04-14 01:01:55 -04:00
Kwabena W. Agyeman
bbb6a0ae92 Add better text drawing.
Non monospace text drawing.
2018-04-08 17:31:51 -04:00
Kwabena W. Agyeman
31b1273fb6 Add draw image for drawing images.
Can also be used to draw sprites by using the mask image to turn off
drawing some pixels.
2018-04-08 00:45:34 -04:00
Kwabena W. Agyeman
aa7386ac5f Add cartoon filtering
It's not as good as mean shift filtering but can approximate it if you
heavily control the image image lighting conditions. That said, it's a
lot faster and less memory than mean shift filtering.
2018-04-07 23:38:38 -04:00
Kwabena W. Agyeman
7f798a8282 Add flood fill
The algorithm itself is setup to be used for future filters.
2018-04-06 00:20:19 -04:00
Kwabena W. Agyeman
7bd8fe45fd Add masking support to replace. 2018-04-01 17:15:28 -04:00
Kwabena W. Agyeman
311607f02b Add masking support to binary. 2018-04-01 16:55:42 -04:00
Kwabena W. Agyeman
6436eb15dc Normalize bilteral filter sigma values.
Its easy to pick sigma now and it works great. Features get nice and
smooth.
2018-04-01 15:54:43 -04:00
Kwabena W. Agyeman
6e02030cbc Add contrast limited adaptive histogram equalization.
This method is fast and super useful.
2018-04-01 15:33:30 -04:00
Kwabena W. Agyeman
09c9d97a70 Add bilateral filtering support
Runs faster than median filtering with a large kernel size. That said,
if sigma is set to low for the particular scene you can get corrupted
pixels if there's too much change in a particular kernel area. Tried a
few things to filter this out but was not successful. Not sure how to
fix... but, turning the sigma up hides the issue. It has something to do
with zeros in the luts used to speed the algorithm up causing
instability.
2018-04-01 00:56:41 -04:00
Kwabena W. Agyeman
c3c40680f5 Add missing binary image filtering functionality
Open/Close/TopHat/BlackHat/MorphMethods/Etc.
2018-03-31 15:06:20 -04:00
iabdalkader
ee2aab62be Add IMLIB_ENABLE_FAST to imlib config. 2018-03-27 03:47:28 +02:00
Kwabena W. Agyeman
a05daabf5b Fix bug with sharpen.
Wayyy too much gain before.
2018-03-26 01:24:24 -04:00
Kwabena W. Agyeman
efe69c961d Add support for scalar operations
This brings all our basic operations code up to spec with other image
library offers.

Anyway, you can now pass a "color" value as the parameter to a basic op
method and it will apply that value to all pixels in the image.
2018-03-20 03:31:24 -04:00
Kwabena W. Agyeman
ed795c4fce Fix possible stack smashing issue.
User could pass too large a kernel size and crash their camera without a
nice error messages.
2018-03-20 00:52:55 -04:00
Kwabena W. Agyeman
74c892abd6 Fixed morph edge methods.
Redcued noise being injected. Looks a lot better now.
2018-03-19 02:41:23 -04:00
Kwabena W. Agyeman
3342f68ca2 Fixed Divide by zero
Saw this floating around.
2018-03-18 22:10:57 -04:00
Kwabena W. Agyeman
d7159fba3e Upate filtering operations
Binary images are now handled. Cleaned up and optimized code. Some speed
gains after shifting to multiplies and not using int8_t.

Added a sharp and unsharp mask feature. Fixed up guassian. Added a
laplacian operation for edge detection.
2018-03-18 22:06:03 -04:00
Kwabena W. Agyeman
45b319dc84 Add the ability to pull higher scaled text kerning in... 2018-03-16 01:27:51 -04:00
Kwabena W. Agyeman
0d63aa52df Fix minor numerical issues.
Couldn't sleep. Needed to make sure this got fixed.

On a side note. We should use a better font. It doesn't really scale
well. Not going to fix now.
2018-03-12 08:51:56 -04:00
Kwabena W. Agyeman
fc74e70c32 Upgrade Drawing Features
Heavily upgraded the drawing features onboard the OpenMV Cam. We now
have all the basic drawing methods folks expect along with all the
parameters you need. Finally! You can make big text fonts.

* Added line thickness support
* Added shape fills
* Added text scaling
* Added draw arrow.
2018-03-12 01:14:03 -04:00
iabdalkader
453b41a6ec Update to latest MP. 2018-03-10 20:14:49 +02:00
iabdalkader
68e761d55a Fix typo in comment. 2018-03-05 19:18:45 +02:00
Kwabena W. Agyeman
e0e112468e Argument Parsing Done Correctly
All of our argument parsing code has now been updated to handle
positional as well as keyword arguments in our python libraries.

Basically, python allows you to pass some number of positional arguments
to functions/methods followed by keyword arguments (you cannot have more
positional arguments after keyword arguments). Previously, our code
would only look for keyword arguments. Now, it works better and will
grab as many positional arguments as it can followed by processing
keyword arguments. Note: If the case of a positional argument value for
a parameter being passed followed by a keyword for that same parameter
the keyword value is taken (since it comes aftward).

Because arguments were passed in keyword form before this update has no
affect on current code. However, moving forward, argument positions are
now locked and cannot be moved around.
2018-03-05 00:49:36 -05:00
iabdalkader
75d89f7172 Add CMSIS CNN. 2018-03-05 03:10:10 +02:00
Kwabena W. Agyeman
397abe4746 Cleanup Math Operations
Add binary image support to the math operations and updated them to
support masks. Replace now also support mirroring operations. Finally,
adding missing basic math ops like add/sub/mul/div. The operations are
designed to work as image blending operations so they take care of
scaling their output accordingly.
2018-02-25 22:03:31 -05:00
Kwabena W. Agyeman
fb3d0776f0 Overhaul Binary Functions
Binary() can noew zero things so you can remove bright lights. All the
line ops (and/or/xor/etc) accept masks. Erode and dilate now accept
masks. And finally, you can now pass arguments versus keywords for folks
who don't read the documentation. Also, the binary image type is now
supported for these methods.

I'm putting in all this work because I saw the need for it when I was
doing shadow removal.

Note: Some effort needs to be put into optimizing the py_image.c code
soon. This is on the todo list before the next release.
2018-02-25 00:15:02 -05:00
Kwabena W. Agyeman
646425b2a6 Add color thresholding support to get_histogram/stats.
You can now pass a color threshold list to get histogram and get stats
(along with an invert arg) to control what gets put into the histogram.
2018-02-21 01:27:13 -05:00
iabdalkader
c8741f5cc1 Rename OMV_ENABLE to IMLIB_ENABLE. 2018-02-02 01:35:13 +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
e0ef7d5bcc Add more ifdefs to remove OpenMV Cam M4 features since we're flash
exhausted.
2018-01-24 01:33:45 -05:00
Kwabena W. Agyeman
fc9c416a21 Frame Differencing with Shadow Removal
Add in support for shadow removal from the current image using a shadow
free background image. Test results show the algorithm works similar to
max() while still keeping dark objects around. The preformance impact of
the algorithm is not too high. An in memory example can achieve 30 FPS.
2018-01-21 16:41:04 -05:00
Kwabena W. Agyeman
38f2c41877 Add pixel and area threshold settings to get_regression()
You can now make it not return anything for images with a low pixel
count.
2018-01-20 01:57:17 -05:00
Kwabena W. Agyeman
432b39bc17 Add min()/max() for frame differencing.
These have cool ghost image like affects and are useful for frame
differencing.
2018-01-17 02:13:55 -05:00
iabdalkader
abf836519f Support bayer pixel access. 2018-01-16 22:59:01 +02:00
Kwabena W. Agyeman
c78f91b421 Phase Corr Redo 2
Redid the phase correlation code again so it's one method call now. This
method call can either do logpolar phase correlation to get rotation/
scale or translation(x/y). Additionally, it will be able to also do both
at once. However, I don't have that quite working yet.

I've updated the example scripts to reflect the new code too.

Finally, I had to fix a bug in the rotation correction code.

...

Once I've got the full pipeline working I will post scripts for that. I
have all the code in there and it's been somewhat debugged... However, I
can't get a useful phase correlation lock out of the log polar fft mag.
I plan to look into noise filtering and spectral whitening solutions for
this.
2018-01-15 23:29:04 -05:00
iabdalkader
4d09a13f30 Use ROI for lenet. 2018-01-12 01:23:03 +02:00
Kwabena W. Agyeman
3da3c60e12 Fixed bugs with logpolar/linpolar.
Images look great now.
2018-01-09 01:25:10 -05:00
Kwabena W. Agyeman
213396d090 Complete Overhaul of phasecorrelation
Just doing one big commit/PR here since I noticed that breaking it up
causes issues.

Anyway, these fixes give us GOOD/WORKING/FAST optical flow now on the
OpenMV Cam M7. A number of changes were made to the optical flow
scripts. You have have absolute and differential estimation example
scripts. Additionally, you also have the ability to measure rotation and
scale changes too. Linear/Log Polar conversion was added for this. Users
may use the new code for generic image manipulation too. Finally, I
updated the power of 2 resolutions since you actually HAVE to use them
with optical flow for the phasecorrelation code to work correctly.

I have some more advanced scripts coming after this. But, This commit is
already getting kinda large so I'm stopping it here.
2018-01-07 17:48:07 -05:00
Kwabena W. Agyeman
cbbead0785 Add adaptive thresholding to filters.
I still need to go back and optimizing and cleanup the code. I just
wanted to get the feature in first.
2017-12-27 19:23:48 -05:00
Ibrahim Abd Elkader
7346efbf0d
Merge pull request #285 from kwagyeman/compare_methods
Compare methods
2017-12-23 22:22:22 +02:00
Kwabena W. Agyeman
e2025e8d1e SSIM Code
Image comparison using SSIM. It can be used to detect image
differences... but, the algorithm was designed to compare image quality
and look at compression artifacts. Anyway, it works kinda okay for
detecting frame differences.
2017-12-23 15:01:13 -05:00
iabdalkader
f2431de175 Add a list of matching keypoints to keypoints match object. 2017-12-21 21:07:01 +02:00
iabdalkader
eabdcbbbca Add unary_op and subscr to keypoints object. 2017-12-21 19:53:20 +02:00
Kwabena W. Agyeman
937aa1fa22 Add chrominace and illuminace invariant image generators.
Both algorithms were tested on the OpenMV Cam using images loaded from a
file and work correctly. However, shot noise from the sensor.snapshot()
makes the output value somewhat worthless except in a situation unless
you've controlled for it. Anyway, the illuminvar work best when the
image is constrained to a very particular view point looking at a flat
scene without shadow and then a shadow enters.

(Not adding demo's for these methods since the output looks like crap
unless you've put some work into constraining the scene... need to add
HDR code and other stuff to the sensor module to get better images).
2017-12-17 21:57:08 -05:00
Kwabena W. Agyeman
8d63f6d84b Fix up lens_correction and add example script. 2017-10-28 00:31:01 -04:00
Kwabena W. Agyeman
5e3cf92ac4 Add perspective rotation correction code.
This code will help you undo image rotation issues in the X/Y/Z
direction. The demo shows off the frame buffer spinning around.
2017-10-27 01:21:13 -04:00
iabdalkader
11bed4b993 Update to MP-1.9.2 2017-10-09 21:20:06 +02:00
iabdalkader
f86a5fb63d Fix blob.density()
* Fix issue #268
2017-10-04 11:00:23 +02:00
Kwabena W. Agyeman
cbe2a4aebd Disable find line segments on the M4. 2017-10-03 02:50:55 -04:00
iabdalkader
9db426394f Update OMV Python modules for MP-1.9 2017-09-21 16:58:57 +02:00
Ibrahim Abd Elkader
0cf13e8777 Merge pull request #263 from kwagyeman/lsd
Lsd
2017-09-13 18:09:50 +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
Kwabena W. Agyeman
7dff089e6f Removed QRCodes from the OpenMV Cam M4.
They don't really work that well on it anyway due to having to use a low
res. This makes room for more basic CV features on the M4 which it can
run.
2017-09-03 14:39:14 -04:00
iabdalkader
4a62b8b989 Add IM_IS_MUTABLE to check if JPEG or RAW image. 2017-08-24 23:42:05 +02:00