opencv-fun | Small OpenCV testbed to try out some ideas
kandi X-RAY | opencv-fun Summary
kandi X-RAY | opencv-fun Summary
Small OpenCV testbed to try out some ideas.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Initializes the camera
- Adds a button to the window
- Adds a label to the window
- Update camera
- Converts a matrix to a buffered image
- Sets the image to be buffered
- Start the application
- Call this method to process the camera
- Updates the background image
- Extracts the ball and clusters inside the given mask
- Update the diff
- Creates a bitmask for the specified camera
- Initialize the screen
- Adds a slider to the window
- Updates the camera view
- Updates the ball detector
- Move the screen to the specified display position
- Initialize camera view
- Detect motion detection
- Reset the focus
opencv-fun Key Features
opencv-fun Examples and Code Snippets
Community Discussions
Trending Discussions on opencv-fun
QUESTION
I am working on a detection of LEGO City Rails to obtain if there is a curve and and whats the curve radius or angle.
As you can see I already cropped the picture. I also used different algorithms for edge detection like canny or just sobel operators.
Unfortunately the railroad ties make it really hard to detect the curve properly. I already tried hough transform, but this doesn't work well. Also the OpenCV-function cv2.findContours
doesn't work very well.
The following picture shows my current status which uses Canny Edge Detection. The red lines in the picture show the lines generated by the probablistic Hough-Transform. I already removed all horizontal lines and all lines with an angle smaller than 10 degree generated by the hough transform.
Why doesn't the hough transform detect all lines in this picture?
Do you guys have any suggestions how I can detect the rails properly?
Thank you in advance!
...ANSWER
Answered 2021-Apr-23 at 12:49import cv2
import numpy as np
def empty(a):
pass
path = 'media/SVIi0.png'
cv2.namedWindow("TrackBars")
cv2.resizeWindow("TrackBars",640,240)
cv2.createTrackbar("Hue Min","TrackBars",11,179,empty)
cv2.createTrackbar("Hue Max","TrackBars",66,179,empty)
cv2.createTrackbar("Sat Min","TrackBars",0,255,empty)
cv2.createTrackbar("Sat Max","TrackBars",255,255,empty)
cv2.createTrackbar("Val Min","TrackBars",21,255,empty)
cv2.createTrackbar("Val Max","TrackBars",255,255,empty)
while True:
img = cv2.imread(path)
imgHSV = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
h_min = cv2.getTrackbarPos("Hue Min","TrackBars")
h_max = cv2.getTrackbarPos("Hue Max", "TrackBars")
s_min = cv2.getTrackbarPos("Sat Min", "TrackBars")
s_max = cv2.getTrackbarPos("Sat Max", "TrackBars")
v_min = cv2.getTrackbarPos("Val Min", "TrackBars")
v_max = cv2.getTrackbarPos("Val Max", "TrackBars")
print(h_min,h_max,s_min,s_max,v_min,v_max)
lower = np.array([h_min,s_min,v_min])
upper = np.array([h_max,s_max,v_max])
mask = cv2.inRange(imgHSV,lower,upper)
imgResult = cv2.bitwise_and(img,img,mask=mask)
cv2.imshow("Mask Images", mask)
cv2.imshow("Original Images", img)
cv2.waitKey(1)
QUESTION
Yesterday I updated my Android Studio included NDK to version 17.0.4754217
and since then I can't run my app anymore. When I tried to rerun the code after the update it gave me the error ABIs [mips64, armeabi, mips] are not supported for platform. Supported ABIs are [armeabi-v7a, arm64-v8a, x86, x86_64]
so I excluded them from the project in my app.gradle
file the following way: abiFilters 'x86', 'x86_64', /*'armeabi',*/ 'armeabi-v7a', 'arm64-v8a'/*, 'mips', 'mips64'*/
.
However, since then I'm having a problem with the C++-file where I use the OpenCV-function cv::CascadeClassifier::detectMultiScale
.
It always displays the error: CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o: In function detectAndDisplay(cv::Mat, double, int, std::__ndk1::basic_string, std::__ndk1::allocator >, cv::CascadeClassifier&)':
D:\Schule\OpenCV\ARcpp\app\src\main\cpp/native-lib.cpp:158: undefined reference to cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::__ndk1::vector, std::__ndk1::allocator > >&, double, int, int, cv::Size_, cv::Size_)'.
I call the function like this: cascadeClassifier.detectMultiScale(frame_gray, sights, scaleFactor, minNeighbours, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
. The rest of the code is pretty much like shown in the OpenCV-tutorial https://docs.opencv.org/2.4/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html.
Additionally to the NDK I use CMake and LLDB and my included OpenCV-library is openCVLibrary320
. Again, all of this worked until I downloaded the mentioned NDK update.
The rest of the error that always appears on building or executing the app is: Build command failed.
Error while executing process C:\Users\chris\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build D:\Schule\OpenCV\ARcpp\app\.externalNativeBuild\cmake\debug\arm64-v8a --target native-lib}
[1/1] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\arm64-v8a\libnative-lib.so
FAILED: cmd.exe /C "cd . && C:\Users\chris\AppData\Local\Android\Sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android --gcc-toolchain=C:/Users/chris/AppData/Local/Android/Sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64 --sysroot=C:/Users/chris/AppData/Local/Android/Sdk/ndk-bundle/sysroot -fPIC -isystem C:/Users/chris/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -std=c++11 -frtti -fexceptions -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot C:/Users/chris/AppData/Local/Android/Sdk/ndk-bundle/platforms/android-21/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -LC:/Users/chris/AppData/Local/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/arm64-v8a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ..\..\..\..\build\intermediates\cmake\debug\obj\arm64-v8a\libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o -llog ../../../../src/main/jniLibs/arm64-v8a/libopencv_java3.so -latomic -lm "C:/Users/chris/AppData/Local/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_static.a" "C:/Users/chris/AppData/Local/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++abi.a" && cd ."
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
I`m really lost, hopefully someone knows an answer.
...ANSWER
Answered 2018-May-13 at 17:13When linkin opencv with your project executables, you always have to link with the general library -lopencv_core. But some packages require additional link flags. For example, if you use highgui as in
QUESTION
I try to show an Image with the OpenCV-function 'imshow()'.
...ANSWER
Answered 2019-Jul-18 at 21:28I found the solution,
the Problem was, that my Code depends in another function from <
this is a ROS Specific lib.
This lib uses Opencv 2.3. I head to use a fork, where someone ported this lib to OpenCV 4 here. Now the whole thing works just fine!
QUESTION
I'm discovering OpenCV v4.1. I downloaded ready to go build version, and unpacked it into my C drive. I'm using VS studio 16 along with cmake to build project. I generate files using Ninja.
That's how my cmake looks like atm:
...ANSWER
Answered 2019-Jul-11 at 12:45You can use the find_package()
and set()
functions to specify the path of your opencv directory and include the directories.
This is what my CMake looks like in Ubuntu.
QUESTION
I'm asking you a very simple question. I want to use the TVL1 function for computing opticalflow with openCV (and python). But here is what I get :
...ANSWER
Answered 2019-Apr-01 at 09:06I found the solution here.
The way to call the function is different with the latest openCV version. Here is what to do :
Replace
QUESTION
In OpenCV 3.4.2 the option to return the number of votes (accumulator value) for each line returned by HoughLines() was added. In python this seems to be supported as well as read in the python docstring of my OpenCV installation:
"Each line is represented by a 2 or 3 element vector (ρ, θ) or (ρ, θ, votes) ."
It is also included in the docs (with some broken formatting). However I can find no way to return the 3 element option (ρ, θ, votes) in python. Here is code demonstrating the problem:
...ANSWER
Answered 2018-Sep-11 at 15:57As of vanilla OpenCV 3.4.3, you can't use this functionality from Python.
How it Works in C++First of all in the implementation of HoughLines
, we can see code that selects the type of the output array lines
:
QUESTION
I build opencv3.2
with cmake and Visual Studio 12 (2013) with CUDA
support and python3.5
. All the libraries were build successfully and I can run opencv
commands with python
.
Here is the output from the command print(cv2.getBuildInformation())
ANSWER
Answered 2018-Jun-21 at 16:46I was able to find a way to get cuda
support for OpenCV python
by following the tutorial in here (I did not test that). As far as I know GPUMat
is not available. But UMat
is available for python which can be used to access OpenCL
.
As described in this answer, UMat
is
A unified abstraction cv::UMat that enables the same APIs to be implemented using CPU or OpenCL code, without a requirement to call OpenCL accelerated version explicitly. These functions use an OpenCL-enabled GPU if exists in the system, and automatically switch to CPU operation otherwise.
As described in OpenCL
section here, you just have to change normal matrices (in python
np.ndarray
s) to UMat
s (in python
cv2.UMat
) to get the OpenCL
support.
But what I do when I need cuda
support is, I write that part as a function in c++
with cuda
support. I make that function to take a cv::Mat
image as the argument and return a cv::Mat
as result.
Then write a python
wrapper for that function as described here.
That is a bit old code. But it worked for me on python 3.5
and python 2.7
with OpenCV 3.4
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install opencv-fun
You can use opencv-fun like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the opencv-fun component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page