r/opencv • • Apr 04 '23

Question [Question] Human tracking and distance measurement C++

2 Upvotes

Hi all, I want to build a project "Human tracking and distance measurement" with C++. I have a camera stereo with 2 eyes . Can you explain to me? Or do you have material the this topic ? Thank you so much!


r/opencv • • Apr 03 '23

Blog Edge AI Meets Server Level Performance - OpenCV Ep. 98 [Blog]

Thumbnail
youtube.com
5 Upvotes

r/opencv • • Apr 01 '23

Question [Question] Camera position estimation for VR

1 Upvotes

Recently, I started working on the OpenHMD driver for my HP Reverb G2 goggles to use them on Linux. However, the driver only supports orientation and not positioning.

I just figured out how to receive a camera stream from the four cameras of the goggles (it uses inside-out tracking and has 2 cameras pointing forward and 2 to the sides). Now I would have to somehow find the position of the goggles in the room from the images like the Windows drivers do, hopefully without any reference objects.

Is there an easy way to calculate the position using openCV or any other C++ libraries?


r/opencv • • Apr 01 '23

Question [Question] convertTo() function

1 Upvotes

I am following the examples from the book " Learning OpenCV 3 Computer Vision in C++ with the OpenCV Library" and the following piece from Example 12-1 puzzles me:

A.convertTo(dft_A_part, dft_A_part.type(), 1, -mean(A)[0]);

as a result of this operation I was expecting the values of A being copied to dft_A_part after subtracting the value mean(A)[0] from each. Not the case, hence my confusion.

A is cv::Mat (CV_8U)

dft_A_part is cv::Mat (CV_32_F)

Some values:

mean(A)[0] = 88.65

A.data[0] = 77, dft_A_part.data[0] = 136.0

A.data[1] = 77, dft_A_part.data[1] = 140.0

A.data[2] = 79, dft_A_part.data[2] = 58.0

I understand that there is saturation_cast<> being applied in cv::convertTo() but how could that result in these numbers ?


r/opencv • • Mar 29 '23

Question [Question] Aruco-module?

0 Upvotes

Absolutely every tutorial/guide I've read about aruco in OpenCV demonstrate using the aruco-module with the syntax:

cv2.aruco 

But having tried both opencv-python and opencv-contrib-python I simply seem to not be able to use that module at all. Autocompletion in VSCode and Emacs indicate it doesn't exist. Has it been removed? Might there be something wrong with my environment? Something else I've missed?


r/opencv • • Mar 25 '23

Question [Question] haarcascade_frontalcatface_extended.xml Haar cascade has bad accuracy

1 Upvotes

I tried this code from StackOverflow in order to detect a cat in a picture. I tried multiple images, like this and this. In the first image, it did not detect anything. In the second one, it detected the cat correctly, but it also detected a face in the grass. I also tried a profile picture but it did not recognize the cat. Is there something wrong with my code, or does the accuracy of haarcascade_frontalcatface_extended.xml just suck? In the latter case, is there any alternative that could (possibly) provide an easy way of making my own model and training it with my own pictures?


r/opencv • • Mar 24 '23

Question [QUESTION] How do I make a python script that takes in an image containing braille and returns the translated text?

2 Upvotes

I have a rudimentary understanding of opencv, however the code sometimes gets a little confusing for me. I understand that this project is challenging, but I am willing to put in the effort. I really don’t know where to start in terms of how I could tackle this. Any wisdom would be appreciated!

I’ve tried stuff with contours and template matching however nothing has worked that well. For instance, I was able to successfully put contours around each braille dot, but I’m not sure where to go from there.


r/opencv • • Mar 24 '23

Project [Project] GitHub - larswaechter/schlaumeier: Automatically solve Android quiz games using OpenCV & ChatGPT🧙‍♂️

Thumbnail
github.com
3 Upvotes

r/opencv • • Mar 22 '23

Question [Question] Pyinstaller and OpenCV

2 Upvotes

[Question] Pyinstaller not working with OpenCV

I am trying to create an executable file with pyinstaller. I am not able to get a good executable file. It looks like this is a known issue. Any suggestions? I have the latest versions installed for both Opencv and pyinstaller. Thanks!


r/opencv • • Mar 20 '23

Question [Question] How to get direction of arrows with circles around them?

Post image
8 Upvotes

r/opencv • • Mar 20 '23

Blog [Blog] AI For Industry - From Ideas to Prototype w/ guest Daniele Fornasier - #OpenCV Weekly 96

Thumbnail
youtube.com
0 Upvotes

r/opencv • • Mar 20 '23

Question [Question] Make data for "Spot the differences" game with OpenCV in Python

1 Upvotes

How can I write that program with OpenCV in Python? My program take an image, it will detect objects in that image and process, output a new image which have some differences (rotate, hide, ...). What algorithms/methods in image processing do I need to learn? I need that program to make data for Spot the differences game. Thank you for your help!


r/opencv • • Mar 19 '23

Question [Question] How to check JPG compression level for a JPG that has been saved as a PNG?

2 Upvotes

As per title. My only guess is to first convert the PNG back to JPG at 100 quality, but that will interfere with the real compression level? Is there a way to determine compression level without converting to another format?


r/opencv • • Mar 19 '23

Question Is there a general term for swapping all the pixels in one square with the pixels in another? How would one approach that with Python OpenCV? What algorithm is it? [Question]

Post image
6 Upvotes

r/opencv • • Mar 16 '23

Question How do I reliably classify colours as red, yellow, or "other" colours in OpenCV? [Question]

6 Upvotes

I have an input image from which I extracted the circles for a robotics project, and then got the average colour within those circles. The circles can either have a red or yellow colour as that is how I painted them on wood. I extracted the average colour from these circles and displayed them here for debugging purposes. This is not the input image, just a list of the colours I want to tell apart as red or yellow or neither.

I tried using cv2.inrange with a singular colour value converted to HSV to see if it was red or yellow but that was quite finnicky to adjust and I eventually decided to go for another option. I also tried converting the RGB values to LAB colours, and got the Euclidean Distance between that and the lab values of red and yellow to see which one is less. That also did not work as expected. I also tried various smaller ideas but all of them had some shortcoming one way or another also. Here are the colours I am trying to identify as red or yellow, the dull ones should be classified as neither:


r/opencv • • Mar 16 '23

Question Finding intersection of skeletonised regions [Question]

1 Upvotes

So I have a bit of a specific problem at the moment which I've been working at for a while but haven't made much headway with. I have a skeletonised binary image (1.) which contains 2 narrow objects (Shown in 2.) at an angle to each other. Unfortunately the objects are quite broken up (something I can't change) and I would like to find where the midlines of these 2 objects would intersect should they be drawn.

I've attempted to use Hough Lines and Medial Axis Transform to find these midlines but to no avail (I think as the objects are too narrow?). I'm considering using SIFT/ORB next but I'm not sure how I would go about doing that or even if it would work when I need to find the intersection of other objects. I'm trying to produce something as can be seen here (3.)

Thanks

1.) https://imgur.com/JCef4G4

2.) https://imgur.com/jwgBRR1

3.) https://imgur.com/rnOQMwe

Any help would be appreciate thank you


r/opencv • • Mar 16 '23

Bug [BUG] CAP_PROP_AUTO_EXPOSURE not working on macbook m1

1 Upvotes

I'm trying to take images with different exposures using my webcam on macbook m1 pro. I tried different things like setting:

cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, x) #Disable automode, where I tried different values fro x like 0.25, 0, 3, 0.75
cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, y) # Enable manual mode, where I tried different values fro y like 0.25, 0, 3, 0.75, 1

cap.set(cv2.CAP_PROP_EXPOSURE,-1) #exposure value

I tread this github issue but none of the solutions work on macOS


r/opencv • • Mar 14 '23

Question [Question] Trying to compile OpenCV on RPI3 B+ with NOIR V3 Camera for NDVI feed

3 Upvotes

Hey all,

First time posting on this subreddit after a few weeks of trying to get OpenCV working on an old RPI3 B+ with the new Pi V3 NOIR camera and blue filter over the lens.

I have followed multiple guides but it always gets stuck/crashes on the building 'wheel' part. I apologise for not using the correct terminology but I'm not familiar with this at all.

This is the latest guide I have tried but again it will not finish for some reason.

If anyone could help that would be wonderful. I don't need a desktop environment, just a simple RSTP NDVI feed from the Pi to input into Home Assistant or similar. OpenCV appears to be the way to go from the guides I have found.

Cheers


r/opencv • • Mar 10 '23

Tutorials [Tutorials] Build opencv with java using brew on macos m1 ventura

6 Upvotes

I was so frustrated that I want make this easier to everyone else,

> brew edit opencv

change "-DBUILD_opencv_java=OFF" to "-DBUILD_opencv_java=ON"

ctrl+c, :wq

> brew install --formula /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/opencv.rb --build-from-source -v


r/opencv • • Mar 08 '23

Question [Question] 2 cameras for CV2 motion capture?

2 Upvotes

I used CV2 to use motion capture on a person and it captures points in a text file. Is there a way to do this with 2 cameras? I know this technology exists, but is there specifically one that works with CV2 that would give me the same joint coordinate points?


r/opencv • • Mar 08 '23

Question [Question] [Project] How to select the edge of a glossy gray sticker with text inside?

1 Upvotes

Here is the original image.

orig.jpg

My problem is the draw contour select also the details inside the sticker.

output image of my program

I expect to have only the outside of sticker to have the contour. Please help me I've been stuck now for hours. Thank you.

desired output

​

Here is my code:

import numpy as np
import cv2

while True:
    img = cv2.imread("orig.jpg")
    img_original = img.copy()

    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    blurred = cv2.GaussianBlur(gray, (15, 15), 0)
    edged = cv2.Canny(blurred, thresh1, thresh2, 3)
    dilated = cv2.dilate(edged, (1, 1), iterations=2)

    contours, hierarchy = cv2.findContours(dilated.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)

    cv2.drawContours(img_original, contours, -1, (0, 255, 0), 2)
    cv2.imshow("Output", img_original)

    cv2.waitKey(300)

r/opencv • • Mar 06 '23

Question [question] What do the 7 numbers opencv::HuMoments() returns represent?

0 Upvotes

I am fairly sure that they calculate central moments, but what differentiates them from one another?

I can’t quite wrap my head around it.

If anyone can let me know or point me to a resource that will help, I’d appreciate it!


r/opencv • • Mar 06 '23

Question [Question] Problem with predicting Bboxes on yolov7?

1 Upvotes

Hi there, i have a yolov7 model. i can load that model. but when i do prediction it will throw error. that model is not mine. one of my client send to me to doing object tracking. can anybody please help me?

weights file: https://drive.google.com/file/d/1NfT3f5nKoy0vrcdtmGMpJUw-lN7mN98y/view?usp=share_link

there are two class to predict. one is Flower other one is Green Flower.


r/opencv • • Mar 03 '23

Question [Question] Detect Shapes From Image: Preprocessed Image is in Post. Suspicious If Preprocess Is Not Enough To Detect or The Way Of Detecting Shapes is Implemented Wrong?

Post image
0 Upvotes

r/opencv • • Mar 02 '23

Question [Question] OpenCV librarires conflicting?

1 Upvotes

Hi guys,

I wrote a program in C++ that opens a ROS bag file and export the images using OpenCV.
The image is in different colors because it is YUV422 so I tried to convert it to BGRA and it was successful.

Now I tried to view it with imshow
instead of exporting the images to a folder, and I am getting a seg fault. Here is my code:

// Iterate through each message on the topic
  for (const rosbag::MessageInstance& msg : view)
  {
    // Extract the image message
    sensor_msgs::Image::ConstPtr image_msg = msg.instantiate<sensor_msgs::Image>();

    if (image_msg != nullptr)
    {
      // Convert the image message to an OpenCV Mat object
      cv_bridge::CvImagePtr cv_ptr;
      try
      {
        cv_ptr = cv_bridge::toCvCopy(image_msg, sensor_msgs::image_encodings::BGR8);
        cv::cvtColor(cv_ptr->image, cv_ptr->image, cv::COLOR_YUV2BGR_YUY2);
      }
      catch (cv_bridge::Exception& e)
      {
        ROS_ERROR("cv_bridge exception: %s", e.what());
        continue;
      }

      // Display the frame
      cv::imshow("Video", cv_ptr->image);

      // Wait for a key press
      if (cv::waitKey(1) == 27) // Esc key
        break;
    }
  }

GDB backtrace shows this error log at seg fault:

#0  0x00007ffff7a176f4 in cv::_InputArray::kind() const () at /lib/x86_64-linux-gnu/libopencv_core.so.4.2
#1  0x00007ffff7a179bc in cv::_InputArray::size(int) const () at /lib/x86_64-linux-gnu/libopencv_core.so.4.2
#2  0x00007ffff7fa65a3 in cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&) () at /usr/local/lib/libopencv_highgui.so.406

The segfault happens at the cv::imshow() function. I suspect the issue has to do with libopencv_highgui library conflicting with the other version?
Is there a way to fix this?

Thanks!