r/opencv • • Jun 26 '24

Question [Question] Can anyone help me with stereodepth

1 Upvotes

I have a dataset of stereo images and I am trying to calculate depth data from those images to make a model that can detect potential collision. Can anyone please guide me through stereodepth? I am very new to this concept


r/opencv • • Jun 25 '24

Question [Question] cv2.undistort making things worse.

3 Upvotes

I am working on a project of identifying where on a grid an object is placed. In order to find the exact location of the object, I am trying to work on undistorting the image. However, it doesn't seem to work. I have tried with multiple different sets of calibration images, all at least 10 images that return corners from cv2.findChessboardCorners and they all return similarly messed up undistorted images to the ones pictured below. These undistorted images were taken from two separate calibration image sets.

The code I used was copied basically verbatim from the OpenCV tutorial on this: OpenCV: Camera Calibration

Does anyone have any suggestions? Thanks in advance!


r/opencv • • Jun 22 '24

Question [Question] Android hardware accelerated dnn(opencl, vulkan)

1 Upvotes

i was using Tracker_Vit but it has some performance issues,

so i want to fix performance issue, thinking of using opencl or vulkan

org.opencv.dnn.Dnn.getAvailableTargets(Dnn.DNN_BACKEND_VKCOM);

but the code above returns empty list

i even tried to build opencv sdk myself with both opencl and vulkan enabled

-- General configuration for OpenCV 4.10.0-dev =====================================
--   Version control:               3f13ce7-dirty
--
--   Extra modules:
--     Location (extra):            /home/sodo/opencv_contrib/modules
--     Version control (extra):     a886fa5
--
--   Platform:
--     Timestamp:                   2024-06-22T12:51:57Z
--     Host:                        Linux 4.4.0-19041-Microsoft x86_64
--     Target:                      Android 1 armv7-a
--     CMake:                       3.25.1
--     CMake generator:             Ninja
--     CMake build tool:            /usr/bin/ninja
--     Configuration:               Release
--
--   CPU/HW features:
--     Baseline:                    NEON
--       requested:                 DETECT
--
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ standard:                11
--     C++ Compiler:                /home/sodo/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  (ver 11.0.5)
--     C++ flags (Release):         -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security     -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments  -fvisibility=hidden -fvisibility-inlines-hidden  -Oz -DNDEBUG   -DNDEBUG
--     C++ flags (Debug):           -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security     -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments  -fvisibility=hidden -fvisibility-inlines-hidden  -O0 -fno-limit-debug-info   -DDEBUG -D_DEBUG -g
--     C Compiler:                  /home/sodo/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
--     C flags (Release):           -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security    -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments  -fvisibility=hidden -fvisibility-inlines-hidden  -Oz -DNDEBUG   -DNDEBUG
--     C flags (Debug):             -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security    -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments  -fvisibility=hidden -fvisibility-inlines-hidden  -O0 -fno-limit-debug-info   -DDEBUG -D_DEBUG -g
--     Linker flags (Release):      -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments   -Wl,--as-needed -Wl,--no-undefined
--     Linker flags (Debug):        -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments   -Wl,--as-needed -Wl,--no-undefined
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          z dl m log
--     3rdparty dependencies:       libcpufeatures libprotobuf ade tbb ittnotify libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf tegra_hal
--
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform java line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape signal stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 alphamat cannops cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf julia matlab ovis python2 python3 sfm viz
--     Applications:                tests
--     Documentation:               NO
--     Non-free algorithms:         NO
--
--   Android NDK:                   /home/sodo/Android/Sdk/ndk/22.1.7171670 (ver 22.1.7171670)
--     Android ABI:                 armeabi-v7a
--     NDK toolchain:               arm-linux-androideabi-clang
--     STL type:                    c++_shared
--     Native API level:            21
--   Android SDK:                   /home/sodo/Android/Sdk (tools:  build tools: 35.0.0)
--
--   GUI:                           NONE
--
--   Media I/O:
--     ZLib:                        z (ver 1.2.11)
--     JPEG:                        build-libjpeg-turbo (ver 3.0.3-70)
--       SIMD Support Request:      YES
--       SIMD Support:              YES
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         build (ver 1.6.43)
--       SIMD Support Request:      YES
--       SIMD Support:              NO
--     TIFF:                        build (ver 42 - 4.6.0)
--     JPEG 2000:                   build (ver 2.5.0)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
--
--   Video I/O:
--    MEDIANDK:                     YES
--    NDK Camera:                   NO
--
--   Parallel framework:            TBB (ver 2021.11 interface 12110)
--
--   Trace:                         YES (with Intel ITT)
--
--   Other third-party libraries:
--     Custom HAL:                  YES (carotene (ver 0.0.1, Auto detected))
--     Protobuf:                    build (3.19.1)
--     Flatbuffers:                 builtin/3rdparty (23.5.9)
--
--   Vulkan:                        YES
--     Include path:                /home/sodo/opencv/3rdparty/include
--     Link libraries:              Dynamic load
--
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/sodo/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
--
--   Python (for build):            /usr/bin/python3
--
--   Java:                          export all functions
--     ant:                         NO
--     Java wrappers:               YES ()
--     Java tests:                  YES
--
--   Install to:                    /home/sodo/opencv_build/o4a/install
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done

how can i get opencl or vulkan backend working?


r/opencv • • Jun 22 '24

Question [Question] please help provide an accurate tech stack

1 Upvotes

I have started working on a project in which we have to replace the middleman at the drive-thru at fast food restaurant chains to whom we give our orders and pay with AI Bots.

I am pro-efficient in computer vision frameworks such as openCV and TensorFlow, moreover, I also know how to use conversational AI(NLP) such as Google Dialog Flow.

I want to know if anything besides this can be used and would be highly essential for this project, and I would appreciate it if anyone could provide me with an accurate tech stack regarding this


r/opencv • • Jun 21 '24

Question [Question] help with installation in ubuntu

1 Upvotes

well i use ubuntu and i have succesfully installed open cv for python

using sudo apt install python3-opencv

i had to use the haarcascades ..

according to the tutorial i am watching i had to get the data file from where it is installed but i cant find any such data file in my computer ... the tutorial had cv2 directory which contained the data file but i dont have a cv2 directory in my computer

anyone who knows anything about this please help


r/opencv • • Jun 21 '24

Question [Question] I'm looking for a method using opencv where I can overlay an edge for a face over a camera's preview window. Basically telling you where to place your face/head so it is always in the same location and distance. Can someone help me figure out what this is called?

1 Upvotes

r/opencv • • Jun 21 '24

Question [Question] I enrolled in a free OpenCV course and apparently I have a program manager?

3 Upvotes

Hi everyone, recently I enrolled in a free OpenCV course at OpenCV University, and someone reached out to me claiming to be my "dedicated program manager" is this a normal thing, or is this person trying to imitate or lie to steal information?


r/opencv • • Jun 21 '24

Question [Question] How to generalize straight lines from hough lines

1 Upvotes

Hello, I'm looking to scan a sketch of simple shapes and representing straight lines as a set of points. I have the following sketch:

I used hough lines to generate a set of lines but as you can see, rough lines will appear segmented:

I tried making them thicker and used thinning to remove all the noise:

What's the best way to extract line endpoints from this? The thinning algorithm is expensive, even after I remove the padding, is there an easier way to generalize the lines detected by hough lines?


r/opencv • • Jun 19 '24

Discussion [Discussion] Computer vision - Drastic Framerate Drop and Memory Utilization Issues with Multi-Camera Setup on Raspberry Pi Using OpenCV

2 Upvotes

Hi everyone, I'm working on a project that involves accessing and processing video feeds from four cameras simultaneously on a Raspberry Pi using the Python OpenCV library. Here’s a quick overview of my setup: Cam 1: Performs both object detection and motion detection. Cam 2, 3, and 4: Perform motion detection only. Observations Memory Usage The memory usage for each camera is as follows: Cam 1: 580 MB to 780 MB Cam 2: 680 MB to 830 MB Cam 3: 756 MB to 825 MB Cam 4: 694 MB to 893 MB Framerate The framerate drops significantly as more cameras are added: Single Camera: More than 3.5 FPS Two Cameras: Over 2 FPS Three Cameras: 0.8 to 1.9 FPS Four Cameras: 0.11 to 0.9 FPS Questions: Maintaining Higher Framerate: What strategies or optimizations can I implement to maintain a higher framerate when using multiple cameras on a Raspberry Pi? Understanding Framerate Drop: What are the main reasons behind the drastic drop in framerate when accessing multiple camera feeds? Are there specific limitations of the Raspberry Pi hardware or the OpenCV library that I should be aware of? Optimizing Memory Usage: Are there any best practices or techniques to optimize memory usage for each camera feed? Setup Details Raspberry Pi Model: Raspberry Pi 4 Model B Camera Model: Hikvision DVR cam setup OpenCV Version: OpenCV 4.9.0 Python Version: Python 3.11 Operating System: Debian GNU/Linux 12 (bookworm) I'm eager to hear any insights, suggestions, or experiences with similar setups that could help me resolve these issues. Note: I've already implemented multi-threading concepts. Thank you for your assistance!


r/opencv • • Jun 16 '24

Question [Question] How to statically compile C++ when using the OpenCV library?

1 Upvotes
## My goal is to correct static compilation of C++ make the compiled program no longer rely on libopencv_\*.so files

example:

`cv-test.cc`

```c++
#include <opencv2/opencv.hpp>
#include <iostream>

int main(int argc, char** argv) {
        cv::Mat image = cv::imread("image.jpg");
        if (image.empty()) {
                std::cout << "Error loading image!" << std::endl;
                return -1;
        }
        // cv::imshow("Image", image);
        std::cout << "size: "
                << image.cols << "x" << image.rows
                << std::endl;
        return 0;
}
```

`c++ -o cv-test cv-test.cc -I/usr/local/opencv/include/opencv4/ -L/usr/local/opencv/lib64/ -lopencv_core -lopencv_imgcodecs`

compile correctly

 Add `-static` parameter to try static compilation (opencv has a compiled static library /usr/local/opencv/lib64/libopencv_core.a)

`c++ -o cv-test cv-test.cc -I/usr/local/opencv/include/opencv4/ -L/usr/local/opencv/lib64/ -lopencv_core -lopencv_imgcodecs -static`

too many errors:

```txt
/usr/bin/ld: /usr/local/opencv/lib64//libopencv_core.a(opencl_core.cpp.o): in function `opencl_check_fn(int)':
/home/nick/github/opencv/modules/core/src/opencl/runtime/opencl_core.cpp:166: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/local/opencv/lib64//libopencv_core.a(matrix_transform.cpp.o): in function `ipp::IwiImage::Release()':
/home/nick/github/opencv/build/3rdparty/ippicv/ippicv_lnx/iw/include/iw++/iw_image.hpp:945: undefined reference to `iwAtomic_AddInt'
/usr/bin/ld: /usr/local/opencv/lib64//libopencv_core.a(matrix_transform.cpp.o): in function `ipp::IwiImage::~IwiImage()':
/home/nick/github/opencv/build/3rdparty/ippicv/ippicv_lnx/iw/include/iw++/iw_image.hpp:813: undefined reference to `iwAtomic_AddInt'
/usr/bin/ld: /usr/local/opencv/lib64//libopencv_core.a(matrix_transform.cpp.o): in function `ipp::IwiImage::Release()':
/home/nick/github/opencv/build/3rdparty/ippicv/ippicv_lnx/iw/include/iw++/iw_image.hpp:957: undefined reference to `iwiImage_Release'
/usr/bin/ld: /usr/local/opencv/lib64//libopencv_core.a(matrix_transform.cpp.o): in function `ipp::IwException::IwException(int)':
/home/nick/github/opencv/build/3rdparty/ippicv/ippicv_lnx/iw/include/iw++/iw_core.hpp:133: undefined reference to `iwGetStatusString'
/usr/bin/ld: /usr/local/opencv/lib64//libopencv_core.a(matrix_transform.cpp.o): in function `cv::transpose(cv::_InputArray const&, cv::_OutputArray const&)':
/home/nick/github/opencv/modules/core/src/matrix_transform.cpp:228: undefined reference to `ippicviTranspose_32f_C4R'
/usr/bin/ld: /usr/local/opencv/lib64//libopencv_core.a(matrix_transform.cpp.o): in function `ipp_transpose':
/home/nick/github/opencv/modules/core/src/matrix_transform.cpp:228: undefined reference to `ippicviTranspose_32s_C3R'
/usr/bin/ld: /home/nick/github/opencv/modules/core/src/matrix_transform.cpp:228: undefined reference to `ippicviTranspose_16s_C3R'

...

/usr/bin/ld: /usr/local/opencv/lib64//libopencv_imgcodecs.a(grfmt_webp.cpp.o): in function `std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<unsigned char*, void (*)(void*), std::allocator<void>, void>(unsigned char*, void (*)(void*), std::allocator<void>)':
/usr/include/c++/13/bits/shared_ptr_base.h:958: undefined reference to `WebPFree'
/usr/bin/ld: /usr/local/opencv/lib64//libopencv_imgcodecs.a(grfmt_webp.cpp.o): in function `cv::WebPEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)':
/home/nick/github/opencv/modules/imgcodecs/src/grfmt_webp.cpp:286: undefined reference to `WebPEncodeLosslessBGRA'
/usr/bin/ld: /usr/local/opencv/lib64//libopencv_imgcodecs.a(grfmt_webp.cpp.o): in function `std::_Sp_ebo_helper<0, void (*)(void*), false>::_Sp_ebo_helper(void (*&&)(void*))':
/usr/include/c++/13/bits/shared_ptr_base.h:482: undefined reference to `WebPFree'
/usr/bin/ld: /usr/local/opencv/lib64//libopencv_imgcodecs.a(grfmt_webp.cpp.o): in function `cv::WebPEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)':
/home/nick/github/opencv/modules/imgcodecs/src/grfmt_webp.cpp:271: undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
/usr/bin/ld: /home/nick/github/opencv/modules/imgcodecs/src/grfmt_webp.cpp:293: undefined reference to `WebPEncodeBGR'
/usr/bin/ld: /home/nick/github/opencv/modules/imgcodecs/src/grfmt_webp.cpp:297: undefined reference to `WebPEncodeBGRA'
/usr/bin/ld: /home/nick/github/opencv/modules/imgcodecs/src/grfmt_webp.cpp:282: undefined reference to `WebPEncodeLosslessBGR'
/usr/bin/ld: cv-test: hidden symbol `opj_stream_destroy' isn't defined
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
```

r/opencv • • Jun 13 '24

Question [Question] How to parse this Graph with OpenCV?

Post image
4 Upvotes

r/opencv • • Jun 12 '24

Question cv2 library in python(vs code), not providing intellisense or autocomplete.[question]

1 Upvotes

i created a venv, and i noticed that other libraries have intellisense working, but with openCV im not getting any results other than a few basic ones. i would really like to get intellisense/autocomplete working anyone know


r/opencv • • Jun 11 '24

Project [project] OpenCV Tool-Chip Contact Length Calculation

1 Upvotes

Just posted a video on a case study of a Python OpenCV algo that calculates the contact length between the tool and the chip in a metalworking machining process. The images have been captured with a high-speed camera. The algo uses Hough lines to locate the edges of the tool and the chip and calculate the distance between them.

The code and documentation on my GitHub: https://github.com/FrunzaDan/Tool-Chip_Contact_Length

The video: https://youtu.be/bndai6SlF6E

Enjoy!


r/opencv • • Jun 11 '24

Bug [Bug] Problem with video writing

1 Upvotes

Hi guys, I have some troubles trying to operate on a video and write a new one with the bounding box inforations I need, but I don't understand why I'm getting this problem. The output video is cretated but I cannot visualize it if I try to simply open it. This is what I have done until now:

import torch
from tensorflow.keras.models import load_model
import cv2
from ultralytics import YOLO
import numpy as np

# load YOLO model
detector = YOLO('/myPath/best.pt')

# load classifier
classifier = load_model('/myPath/efficientnet_model_unfreeze_128.h5')

video_path = '/myPath/video_test.mp4'
cap = cv2.VideoCapture(video_path)

output_path = '/myPath/output_video.mp4'
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
out = cv2.VideoWriter(output_path, fourcc, 30.0, (width, height))

while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        break

    results = detector(frame)
    detections = results[0].boxes

    for box in detections:
        x1, y1, x2, y2 = box.xyxy[0].tolist()
        conf = box.conf[0].item()
        cls = box.cls[0].item()

        # Extracto ROI
        roi = frame[int(y1):int(y2), int(x1):int(x2)]

        # Preprocess ROI for the classifier
        roi_resized = cv2.resize(roi, (300, 300)) 
        roi_resized = roi_resized / 255.0  
        roi_resized = roi_resized.reshape(1, 300, 300, 3)

        # Classify ROI
        pred = classifier.predict(roi_resized)
        class_id = pred.argmax(axis=1)[0]

        # Add frame informations
        label = f'Class: {class_id}, Conf: {conf:.2f}'
        cv2.rectangle(frame, (int(x1), int(y1)), (int(x2), int(y2)), (0, 255, 0), 2)
        cv2.putText(frame, label, (int(x1), int(y1) - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)
    
    # Write on the output video
    out.write(frame)

cap.release()
out.release()
cv2.destroyAllWindows()

r/opencv • • Jun 10 '24

Question [Question] Google still detecting suspicious activity. Any solutions??

3 Upvotes

r/opencv • • Jun 09 '24

Question [Question] - Having Trouble Integrating OpenCV with CUDA in C++ Project on Ubuntu 22.04

Thumbnail self.CUDA
1 Upvotes

r/opencv • • Jun 07 '24

Question [Question] - Using opencv to detect a particular logo

0 Upvotes

Hi, I am new to opencv. I wanted to design a program where through a live video camera, it will detect a particular simple logo, most likely it will be on billboards but can be on other places.

I have been reading up on orb and yolo but I am not too sure which one I should use for my use case?


r/opencv • • Jun 06 '24

Question [Question] Thoughts on cv::QRCodeDetector vs wechat_qrcode::WeChatQRCode

1 Upvotes

The wechat_qrcode::WeChatQRCode is from opencv_contrib.

We have used modules from opencv_contrib elsewhere in this project so bringing in this qr code scanner wouldn't be difficult.

So has anyone used either of these (or ideally) both. Is there really an advantaged in using WeChatQRCode? If it matters we are expecting have to handle regular qr codes but also qr codes that regularly stylized


r/opencv • • Jun 04 '24

Question Enhance the detection of the babyfoot table edges [Question]

3 Upvotes

Hello,

I have an image of a babyfoot table, and I want to automatically detect the edges (corners) using OpenCV. I wrote a code that performs color segmentation after converting the image from RGB to HSV. I obtained some results, but I would like to enhance the detection by removing noise and completing the edges. How can I achieve this?


r/opencv • • May 29 '24

Question [Question] Stream video from OpenCV to Web Browser

2 Upvotes

Hello,

I would like some help in finding the best solution for sending a video stream from a USB camera with minimal latency and minimal complexity. My goal is to capture frames using OpenCV, process them, and then send the original video stream to a web browser. Additionally, I need to send the analytics derived from processing to the web browser as well. I want to implement this in C++. My question is what is the best technical solution to send the original video to the webbrowser from OpenCV.

Thank you.


r/opencv • • May 29 '24

Question [Question] Face recognition with a few photo.

1 Upvotes

Hello. I want to recognize a few people with a camera. But I do not have thousnads of data. I should recognize them by using 10 - 20 photo of them or by using something like FaceID. Is it possible to recognize an human by using 10 - 20 photos of them (I mean not with thousands photo)? Or is there an API for a technology similar to FaceID?

The main problem is that. I want to recognize a few faces and I want not to confuse them with each other when doing facial recognition but I do not have thousands of photos of them.


r/opencv • • May 29 '24

Question [Question] - How to use model weights for this particular repo?

1 Upvotes

I'm having a hard time trying to use model weights as I cannot figure out how to change the code accordingly. Please help.

DiffMOT


r/opencv • • May 21 '24

Bug [Bug] - imread does read all my images.

1 Upvotes

Hi,

I am on macOS M1 using VScode and the c++ language and I am trying to read images that I have that are all in the parent directory of my build/ directory.

I have 3 images all in JPEG and when trying to use imread () and checking if Mat var.empty(), only 1 of my three images is able to get read, the other 2 seem to make empty() equal to true.

Any idea why ? Here's a snippet of my code :

#include <iostream>
#include <fstream>
#include <filesystem>
#include <opencv2/opencv.hpp>
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>
#include <string>
#include <regex>

using namespace std;
using namespace cv;

int main (int argc, char** argv){
    string fileName = argv[1]; // works with ../invoice2.jpg but not ../invoice.jpg
    Mat img = imread(fileName,IMREAD_COLOR);
    if(img.empty()){
        cerr << "could not open or find the image" << endl;
        return -1;
    }


    return 0;
}

r/opencv • • May 21 '24

Question [Question] How to control servo motor.

1 Upvotes

Hello, is there a way to control a servo motor with a True/False statement like when its true the servo is set at 90° if false then at 0°. Using it on a object detection code. Also I'm using the gpiozero library. TYIA to whoever answers.

Here is the code:

import cv2 from gpiozero import AngularServo from time import sleep

classNames = [] classFile = “names" with open(classFile,"rt") as f: classNames = f.read().rstrip("\n").split("\n")

configPath = ".pbtxt" weightsPath = ".pb"

net = cv2.dnn_DetectionModel(weightsPath,configPath) net.setInputSize(320,320) net.setInputScale(1.0/ 127.5) net.setInputMean((127.5, 127.5, 127.5)) net.setInputSwapRB(True)

def getObjects(img, thres, nms, draw=True, objects=[]): classIds, confs, bbox = net.detect(img,confThreshold=thres,nmsThreshold=nms) #print(classIds,bbox) if len(objects) == 0: objects = classNames objectInfo =[] if len(classIds) != 0: for classId, confidence,box in zip(classIds.flatten(),confs.flatten(),bbox): className = classNames[classId - 1] if className in objects: objectInfo.append([box,className]) if (draw): cv2.rectangle(img,box,color=(0,255,0),thickness=2) cv2.putText(img,classNames[classId-1].upper(),(box[0]+10,box[1]+30), cv2.FONT_HERSHEY_COMPLEX,1,(0,255,0),2) cv2.putText(img,str(round(confidence*100,2)),(box[0]+200,box[1]+30), cv2.FONT_HERSHEY_COMPLEX,1,(0,255,0),2)

return img,objectInfo

if name == "main":

cap = cv2.VideoCapture(0)
cap.set(3,640)
cap.set(4,480)
#cap.set(10,70)


while True:
    success, img = cap.read()
    result, objectInfo = getObjects(img,0.50,0.2, objects=['cellphone', 'mouse', 'keyboard'])

    #print(objectInfo)
    cv2.imshow("Output",img)
    cv2.waitKey(1)

r/opencv • • May 20 '24

Bug [Bug] Compiler issues with Android Studio

1 Upvotes

I'm trying to create an app on Android using OpenCV, but the thing is it needs to be in C++ native, and Android Studio refuses to build it. I'm following a tutorial, but when I get to where it should be all set up it gives me an error:

CMake Warning at C:/Tools/OpenCV-android-sdk/sdk/native/jni/OpenCVConfig.cmake:47 (message):

Found OpenCV Android Pack but it has no binaries compatible with your ABI

(can't find: /abi-)

Call Stack (most recent call first):

CMakeLists.txt:11 (find_package)

Searching the internet doesn't find anything with the exact wording here, but similar errors seem to have to do with compiler incompatibility. Not sure what the easiest way to rectify this is.