OpenCV

Converting vector<Point3d> to a Mat of size (n x 3) and vice versa

馋奶兔 提交于 2021-01-27 19:32:51
问题 I have point clouds in the form of a vector of Point3d (vector). If I use the conversion provided by OpenCV, like cv::Mat tmpMat = cv::Mat(pts) //Here pts is vector<cv::Point3d> It gets converted into a Matrix with 3 channels. I want a single channel matrix with the dimensions nx3 (n - the number of elements in the vector). Is there any direct method to convert a vector of Point3d into an OpenCV Mat of size nx3? Now I'm doing cv::Mat1f tmpMat = cv::Mat::zeros(pts.size(), 3, cv::CV_32FC1); for

How to get value of pixels which are at a certain angle from another pixel?

坚强是说给别人听的谎言 提交于 2021-01-27 18:41:12
问题 I'm trying to implement a method where I have to obtain the values of all those pixels which forms a line at a certain angle through a pixel (i, j) Consider the following code snippet sum = image.getpixel(((i - 7), (j + 2))) + image.getpixel(((i - 6), (j + 2))) + image.getpixel( ((i - 5), (j + 1))) + image.getpixel( ((i - 4), (j + 1))) + image.getpixel(((i - 3), (j + 1))) + image.getpixel(((i - 2), (j + 1))) + image.getpixel( ((i - 1), j)) + image.getpixel((i, j)) + image.getpixel(((i + 1), j

Window freezing even after using waitKey() and destroyAllwindows() in Opencv

北慕城南 提交于 2021-01-27 18:36:05
问题 ENVIRONMENT OS- mint Linux, using opencv3.1,using spyder through anaconda ISSUE The code mentioned below opens a window of name frame and display the video captured through laptop camera.But when I press 'q', as mentioned in code, it should stop and terminate the window. But,here the window stops to display any further frames captured and do not terminates.then manually I force Quit the process. What is the problem, why is it not terminating the window? CODE:- import cv2 import numpy as np

Building cv_bridge Package with ROS Kinetic and Python3 ignoring Cmake Arguments

。_饼干妹妹 提交于 2021-01-27 18:17:52
问题 I'm trying to integrate a ROS package into our system for a research project and the cv_bridge package and python3 is needed in order to get the package working. Currently I can't get the cv_bridge package to build in python3 despite multiple steps, constantly builds in python2 directory. Working in Ubuntu 16.04 with ROS kinetic. Using python3.5 Error Message: [ERROR] [1563897986.999724]: bad callback: <function color_callback at 0x7f00ffa06598> Traceback (most recent call last): File "/opt

Finding object boundaries which are close to each other

时光总嘲笑我的痴心妄想 提交于 2021-01-27 18:01:06
问题 I am working on a computer vision problem, in which one step in the problem is find the locations where the objects are close to each other. Example, in the image below I am interesting in finding the regions marked in gray. Input : Output : My current approach is to first invert the image, followed by morphological gradient follower by erosion, then removing some non-interesting contours. Script is as follows: img = cv2.imread('mask.jpg', 0) img = (255 - img) kernel = np.ones((11,11), np

Undefined References Error OpenCv Android with ndk 18 (c++_static)

為{幸葍}努か 提交于 2021-01-27 17:30:23
问题 I updated Android Studio to use the ndk18 and changed: APP_STL := c++_static This lead to a bunch of linker errors in OpenCv: ../thirdparty/opencv-android-sdk/sdk/native/jni/../libs/arm64-v8a/libopencv_objdetect.a(detection_based_tracker.cpp.o): In function `cv::DetectionBasedTracker::updateTrackedObjects(std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > > const&)': detection_based_tracker.cpp:(.text._ZN2cv21DetectionBasedTracker20updateTrackedObjectsERKSt6vectorINS_5Rect_IiEESaIS3

Linking OpenCV 4.1.0, include works, libs doesn't

只谈情不闲聊 提交于 2021-01-27 13:52:12
问题 After changing Ubuntu from 16.04 to 18.04 and OpenCV from 3.4.1 to 4.1.0 i can't compiled... anything Step by step: I downloaded source code from github, set those flags: cmake -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules cmake -DENABLE_PRECOMPILED_HEADERS=OFF -DBUILD_opencv_cudacodec=OFF -D OPENCV_GENERATE_PKGCONFIG=ON -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D WITH_TBB=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D WITH_QT

How to decrease frame rate of USB webcam 2.0 using openCV python

别来无恙 提交于 2021-01-27 13:20:51
问题 I am working on ubuntu 16.04 and using a USB 2.0 webcam. I want to decrease the frame rate somehow since the project I'm working on requires face detection which really lags the video hence want to decrease the frame rate. I've tried implementing the following code import cv2 cap = cv2.VideoCapture(0) cap.set(cv2.CAP_PROP_FPS, 15) fps = int(cap.get(5)) print("fps:", fps) while(cap.isOpened()): ret,frame = cap.read() if not ret: break cv2.imshow('frame', frame) k = cv2.waitKey(1) if k == 27:

ValueError: too many values to unpack python 2.7

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-27 13:16:43
问题 So I am trying to compile the following code but it's showing me the error on cv2.findContours. Though, I am using Python 2.7 version. Any reason as to why the error: too many values to unpack python 2.7 is coming? import cv2 import numpy as np import time #Open Camera object cap = cv2.VideoCapture(0) #Decrease frame size cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1000) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 600) def nothing(x): pass # Function to find angle between two vectors def Angle(v1,v2): dot = np

How to make a jpg image semi transparent?

老子叫甜甜 提交于 2021-01-27 13:10:33
问题 I want set alpha channel to a .jpg image and set its value to 0.5 or 50% or at 128 (0 to 1 total range or 0-255 range) and save it as .png using only opencv and numpy. I know how to do it using other libraries but we have been asked to perform the above question using only two library i.e. import cv2 and import numpy. i have added the alpha channel but i do not know how to set its value to 50% transparency, please help as I am new to opencv-python. I have tried this code but I am getting a