Comments (7)
Example in the documentation is wrong because it doesn't use string. However generally this approach should work:
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ["OPENCV_FOR_THREADS_NUM"] = "3"
>>> import cv2
>>> cv2.getNumThreads()
3
Default value without environment change:
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.getNumThreads()
4
from opencv.
Most probably the same as https://stackoverflow.com/questions/5153547/environment-variables-are-different-for-dll-than-exe. It's not related to OpenCV, but OS specific.
from opencv.
Dear @LaurentBerger,
I understood the Python Doc but I honestly don't know what to understand in your quoted paragraph. 😕
What I said is that the code provided inside the OpenCV Doc to modify os environment variable, executed as is, raises an error.
The code that reads a video frame doesn't matter much, and it's embedded through MMCV that uses OpenCV, so I'm not able to provide a OpenCV-code-only example. I know this part works, because as I said, it works once the environment variable modified inside Windows parameters.
Please tell me if you really need an example for reading a video frame but I think it's not necessary, as I guess the problem will occur on the set up of every possible OpenCV environment variable.
from opencv.
first read python doc :
I don't see anything in your code about reading a video
from opencv.
i meet with same problem
from opencv.
os.environ["MY_ENV_VARIABLE"] = True
True is not a string
and now I search in doc and I found reference:
I think you can make a PR to change python code
from opencv.
I don't understand : opencv documentation is wrong for python
there is a bug in opencv documentation because if you follow documentation it raises an execption
from opencv.
Related Issues (20)
- onnx dnn performance decreases in multithreading HOT 3
- "How to contribute to OpenCV" is out of date. HOT 1
- DirectShow get device name not free HOT 1
- build wasm fail on opencv 4.10.0 HOT 8
- get different result while invoke connectedComponentsWithStats function with multi thread HOT 2
- Implement cv::cuda::extractChannel
- DNN Input Remains The Same Even After Setting New Input
- Unable to install OpenCV Java on Mac
- How to build static library for iOS?
- Sporadic failure at Layer_Einsum_Test.Accuracy_01D/1, where GetParam() = ({ 1 }, {}, "i,->i") HOT 1
- (.note.gnu.property+0x0): data is too short error during IPP linkage with NDK 27 for Android x86 HOT 5
- Parallel support for filter engine
- Add type handling to TopK layer
- fitEllipse returns a very far ellipse HOT 3
- Missing opencv_world4100.dll and opencv_world4100d.dll in Bin Folder during Extraction using GitHub Actions
- blobRectsToImageRects,This function has an error
- cv::HoughLinesProbabilistic segmentation fault hough.cpp:692 HOT 1
- error: ‘cvLoadImage’ was not declared in this scope HOT 1
- Crashes when dealing with large images
- C++ no includes on get-started page on OpenCV.org HOT 1
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 opencv.