Comments (7)
{:error, "empty matrix"}
love it! Or {:error, "null matrix"}
. :)
from evision.
Massive thanks to @josevalim for the Errorize
demo code. Works like a charm!
from evision.
Notes, for some functions, OpenCV decides to print warnings (tested on OpenCV 4.5.5) instead of reporting error to us, i.e., the NIFs.
For example, for the imread
function
iex(1)> mat = OpenCV.imread!("/path/to/non/exist/image.png")
[ WARN:0@0.008] global /Users/cocoa/Git/evision/3rd_party/opencv/opencv-4.5.5/modules/imgcodecs/src/loadsave.cpp (239) findDecoder imread_('/path/to/non/exist/image.png'): can't open/read file: check file path/integrity
iex(2)> mat
nil
from evision.
@cocoa-xu can you configure it to return an error instead?
from evision.
This seems to be its intended behaviour, according to their docs
The function imread loads an image from the specified file and returns it. If the image cannot be
read (because of missing file, improper permissions, unsupported or invalid format), the function
returns an empty matrix ( Mat::data==NULL )
And since everything is immutable in Erlang/Elixir, I think returning a nil
instead of returning a reference to an empty mat is probably fine?
from evision.
I see, makes sense. It would be nice if we could return {:error, "no result"}
in this case but I understand it may be hard to automate this.
from evision.
In C++, OpenCV returns a valid cv::Mat
object but everything is 0
.
cv::Mat img = cv::imread("/dev/null");
std::cout << img.cols << "\n";
// output: 0
In opencv-python
, the result is None
>>> import cv2
>>> mat = cv2.imread("/dev/null")
>>> mat is None
True
But sure, I can return an error tuple for this. However, I can only do this for general like when converting from cv::Mat
to ERL_NIF_TERM
.
Perhaps we could return {:error, "empty matrix"}
?
from evision.
Related Issues (20)
- NIF error returned from Evision.VideoIORegistry.getBackendName/1 HOT 3
- How to know which VideoCapture backends are actually available? HOT 10
- 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
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.