Comments (3)
Hi @kipcole9, I see the problem here. It wasn't actually an off-by-one error. It is because of OpenCV's inconsistent way of storing the dims of a Mat.
A 4x3x3
mat could be initialised in two ways:
cv::Mat::Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0)
e.g.,Mat(3, [4, 3, 3], CV_8U, data)
cv::Mat::Mat(int rows, int cols, int type, void * data, size_t step = AUTO_STEP)
e.g.,Mat(4, 3, CV_8UC3, data)
Both of them will give the same result on the surface, however, mat.size.dims
from the first one will give [4,3,3]
while the second one will be [4,3]
, and the left dims info, the last 3
, will be stored in channels. (And as you may have guessed, the channel info of the first one is also 3
, causing the {3, 4, 3, 3}
shape)
So the fix in Evision's code is always using from_binary_by_shape
when converting a tensor to a mat, and pass the type as CV_8U/CV_32F/etc, so that we can check mat.type()
to know if we should include the channel number as the last dim in the shape later.
from evision.
Thank you very much @cocoa-xu. I find it difficult to get the mental model of OpenCV straight in my head and its been many many years since I did anything in C/C++ so I find the API docs difficult to decode. So I worry that I will bother you with stupid questions. I'm just happy this one wasn't too stupid. And I really appreciate the fix.
I have tensors/matrices round tripping between Image and OpenCV working well. But I haven't been able to get the image to be correctly resolved in eVision. Hopefully its mostly the issue you outlined above! I'll report back if/when I get that resolved. Then I'm going to add a simple API wrapping the QRCodeDetector module as a first step.
from evision.
Hi @kipcole9, please don't worry about that. I'm always happy to help! This is also a learning process for me. I guess we could say that OpenCV is a large project, and some of its "weird" designs may be due to historical reasons.
Please let me know if there is anything I can do in this project to help you! (I'll be looking at #76 this week. It's not hard to do but will introduce breaking changes)
from evision.
Related Issues (20)
- Design a logo for this library HOT 3
- Failed compile from upstream source HOT 15
- CUDA Error on Windows 11 HOT 1
- Move constants to module `Evision.Constant`
- Evision.VideoCapture.set/3 type inconsistent with retval HOT 1
- CUDA support on Windows HOT 8
- Examples/Tests for modules in opencv_contrib
- Incorrect RPATH for libopencv_cudalegacy.so on Linux HOT 5
- An error occurs when executing the warpAffine function HOT 2
- `warpPerspective` error when executing Text Recognition HOT 3
- Could not compile dependency :complex, "mix compile" failed. HOT 6
- `Evision.Zoo.TextRecognition.CRNN.init/2` failing to download charset HOT 1
- [Possible bug] Wrong typespec for the color parameter in drawContours() HOT 2
- Restructure README.md and move some of it to the wiki page
- Text recognition failing in the latest versions HOT 4
- Unexpected crash without any errors during face detection HOT 4
- Documentation Enhancements
- Consider make available precompiled binaries with FFmpeg included HOT 3
- Error compiling on Elixir 1.15.0/OTP 26.0.1 on M1 Mac with EVISION_PREFER_PRECOMPILED=true HOT 6
- Not able to use Evision Library with Elixir 1.14.4-otp25 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from evision.