Improvements around C++ code + better error handling + two new OpenCV functions + clearBuffers support for skipping some objects (by ids) #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a big diff that I've accumulated while integrating this project into one of my projects. I'm not sure about the changes in
build.gradle
, especially the one pinning the react-native version, but that helped me get gradle and Android Studio to work and to help with C++ code while working on this.Trying to resume the changes:
calcOpticalFlowPyrLK
andphaseCorrelate
OpenCV functionsinvoke
C++ function (check argumentcount
before asserting the type, because otherwise we're accessing out of bounds indexes in the arguments array -> bad memory access?)FOCV_FunctionArguments
and throw some errors if the index is out of bounds + also implemented a type check before trying to cast (if the index check passed) + implemented some new OpenCV types (I thinkTermCriteria
is the only one?)FOCV_Object
Mat creation when given an array with existing data (it didn't respect the number of channels specified in the requested type, always reshaping to 1) + improved array value extraction performance (reserved the required length ahead of time) + again added some index checks for vectors - other small fixes?FOCV_Storage::clear
so you can exclude some objects from the cleanup because you might need them later (I used this lib in combination with react-native-vision-camera, and inside the frame processor - a function that runs for each frame from the camera - I did some opencv stuff and I needed to retain an image for the next loop while clearing the other stuff to avoid filling the memory and to improve performance) - the implementation is questionable as it accepts an array of ids due to simplicity, so in js you'd have to pass[opencvObject.id]
instead of[opencvObject]
I opened the PR because I considered it's a nice improvement that would benefit everybody, but it's not very refined, well tested and very well documented yet, so any feedback is welcome. I might revert some changes, especially from the
build.gradle
, but they don't seem to break anything yet. Also, these changes shouldn't introduce any breaking change. Also, I didn't test very much on iOS, but will do in the near future.PS: Thank you for this library!
PS PS:
calcOpticalFlowPyrLK
works pretty well, that's the one I'm mainly using, butphaseCorrelate
I'm not so sure of, I tested it a little and it was outputting some values, but they seemed strange to me, but maybe I didn't fully understand it. I was wondering if I'm doing some bad casting, but not sure.