Python-OpenCV | Assorted OpenCV programs | SDK library
kandi X-RAY | Python-OpenCV Summary
kandi X-RAY | Python-OpenCV Summary
Assorted OpenCV programs
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Uploads and saves the image .
- Absolute difference between t0 and t2 .
- Read image from file .
Python-OpenCV Key Features
Python-OpenCV Examples and Code Snippets
Community Discussions
Trending Discussions on Python-OpenCV
QUESTION
I know this question has been asked for several times, e.g., this one, but my problem is I need to overlay a smaller PNG image with a larger PNG image, where both images need to maintain their transparency in the output.
For example, smaller image is like: ... larger image is like: (The image above has only 1 pixel filled with white color and 90% transparency)
Using the code examples given in the previous question (overlay a smaller image on a larger image python OpenCv), the larger background image will be in black.
...ANSWER
Answered 2022-Mar-28 at 09:36This is actually the correct output. Fully transparent images (like your template image) have the pixel value of 0 on empty areas which represents black. If you were to use semi-transparent templates (which have pixels value greater than 0 even if they are slightly transparent). You should see this:
Answer 2:
Your output images are 24bit. (Which means you get rid of thhe alpha channel before saving it). I looked into your code and saw the lines 34 and 35;
QUESTION
Things work fine for 30 minutes to an hour, then I get the following error:
...ANSWER
Answered 2022-Feb-17 at 03:17I have added if(ret == True): to the following and there have been no errors for six hours:
QUESTION
I need to use the selectROI function for my project. However, I just can't seem to wrap my head around the format of the coordinates. According to this link, the coordinate array should be in this form: [Top_X, Top_Y, Bottom_X, Bottom_Y]. Assuming that the top left corner starts at (0,0) for (x,y), why are my coordinates so off when I draw 3 different bounding boxes using the selectROI function?
This is what I used to create my bounding boxes and output the coordinates:
...ANSWER
Answered 2022-Feb-11 at 15:25The explanation on geeksforgeeks is wrong or at least easy to misunderstand: the last two values are not coordinates for the bottom-right corner, they are width and height of the rectangle. Notice that e.g. for the third rectangle, the height (161) is roughly twice the width (79), which matches the appearance of the rectangle.
QUESTION
I have a dataset of memes' URLs which I wanna extract their texts from them. I have this function:
...ANSWER
Answered 2022-Feb-01 at 18:40I fixed it by adding the following line after opening the image:
QUESTION
How can i send all webcams to collect from one server. For example:
there is pc_1, pc2, ..., pc_n they are sending camera view to some ubuntu server where i can connect with
ssh name@ip_adress
and all pc have a windows on them
i looked Sending live video frame over network in python opencv this but this worked only on localhost
and secondly i looked this Forward RTSP stream to remote socket (RTSP Proxy?) but couldnt figure out how to do it on my situation
ANSWER
Answered 2022-Jan-28 at 22:52Each IPC is a RTSP server, it allows you to pull/play RTSP stream from it:
QUESTION
I am trying to install ROS Melodic using the instructions on wiki.ros.org and stumbled upon some problems.
System software information:
Operating System: Kubuntu 21.10
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2
Kernel Version: 5.13.0-19-generic (64-bit)
Graphics Platform: X11
ProblemI have first followed steps from http://wiki.ros.org/melodic/Installation/Ubuntu and later followed the steps from https://varhowto.com/install-ros-melodic-ubuntu-18-04/#Step_1_%E2%80%94_Install_ROS_Melodic_repo , both with unsuccessful results.
When running sudo apt update
I am getting:
ANSWER
Answered 2021-Dec-12 at 22:41You're getting this error because Melodic is the ros distro for Ubuntu 18.04. As of present the most recent release is Noetic which targets 20.04. The version of Ubuntu you're using does not currently have a supported ROS release, as such your only real option is to downgrade if you want ROS.
QUESTION
A Linux newbie here. On Linux Mint, python 3.8, under Anaconda, trying to install opencv-contrib-python by
...ANSWER
Answered 2021-Nov-04 at 16:11Removing Anaconda and working with the python supplied with my Linux distro solved the issue.
QUESTION
I'm creating a program the requires a black and white image and two arrays containing the X and Y coordinates of both black and white pixels respectively. I have a program that utilizes OpenCV and binary thresholding to create a black and white image (code source). Hear is the code I have in full so far.
...ANSWER
Answered 2021-Aug-29 at 15:41Replace those two lines of code with the following lines:
QUESTION
I am using Python-OpenCV to detect shapes, measure their distance from the camera lens, and eventually measure the angle of the rotation of the shapes with respect to the camera.
This is what it looks like when the shapes are parallel to the camera
This is what it looks like when the shapes are slightly tilted/rotated
I am trying to determine the angle of rotation of the board on which the shapes are placed, which is why I came up with the idea of comparing the lengths of the parallel sides of the rectangle to each other (any other Idea or tip is greatly appreciated). Required Lengths
The idea is that when the board is rotated, the parallel sides are no longer of equal length and I might be able to come up with a relation between the difference in length and the angle of rotation. I am open to any other suggestions.
I am struggling with calculating those lengths as shown in the picture above. I am trying to avoid using Hough Lines, and stick to Contours, since they proved to be a bit unstable in a live video.
Thank you in advance!
...ANSWER
Answered 2021-Aug-01 at 18:27This code will give you the 4 corners.
QUESTION
I am OCR-ing a bunch of pdf-files. This works fine, but parts of the pdf's are black-lined. Actually, they are not really black-lined but 'rectangled with some text within the rectangels'. This text is messing up my OCR, even while using a word-list for targetting the various combinations of '(10)(2e)'.
I am working with .jpg's, converted from pdf's that contain bot text & images (with text in it). Here's a sample:
Since many variations of the '(10)(2e)' are messing up my OCR, my goal is find all rectangles - that most likely contain '(10)(2e)' and fill them. For finding the rectangles I followed this great answer from nathancy: How to detect all rectangular boxes python opencv without missing anything
However - as you can see in the upper green rectangle - sometimes the green rectangles overlap part of the data I need. In this case "@leiden.nl" and "@" in the second line.
I have experimented with many combinations of both (a) other settings for image processing (erode/dilate/blur/thershold) and (b) other settings as suggested in the answer by Nathancy (kernel settings/number of iterations).
What would be best practice for finding the smaller rectangles?
FYI: My code for finding the rectangles is more or less similar to Nathancy's answer:
...ANSWER
Answered 2021-Jul-03 at 20:46# https://stackoverflow.com/questions/59979760/how-to-detect-all-rectangular-boxes-python-opencv-without-missing-anything
import cv2
import os
path = os.getcwd()
print(path + '/test_ocr3/_stuff_IN/')
# Load iamge, grayscale, adaptive threshold
# image = cv2.imread(path+'/test_ocr3/_stuff_OUT/'+'1.png')
# image = cv2.imread(path+'/test_ocr3/_stuff_OUT/'+'page_1.jpg')
image = cv2.imread(path+'/test_ocr3/_stuff_OUT/'+'page_1_opt.jpg')
# image = cv2.imread(path+'/test_ocr3/_stuff_OUT/'+'page_1_A_erode_551.jpg')
# image = cv2.imread(path+'/test_ocr3/_stuff_OUT/'+'page_1_B_dilate_551.jpg')
# image = cv2.imread(path+'/test_ocr3/_stuff_OUT/'+'page_1_D_threshold_177255.jpg')
result = image.copy()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
thresh = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, 51, 9)
# Fill rectangular contours
# CHECK OTHER CONTOUR SETTINGS ? TO EXLCUDE OUTER ?
# https://docs.opencv.org/master/d9/d8b/tutorial_py_contours_hierarchy.html
# https://medium.com/analytics-vidhya/opencv-findcontours-detailed-guide-692ee19eeb18
# cnts = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cv2.findContours(thresh, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]
for c in cnts:
cv2.drawContours(thresh, [c], -1, (255, 255, 255), -1)
cv2.drawContours(thresh, [c], -1, (0, 0, 0), 1)
# Morph open
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (7, 4))
opening = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel, iterations=4)
# opening = cv2.morphologyEx(thresh, cv2.MORPH_CLOSE, kernel, iterations=4)
# Draw rectangles
# cnts = cv2.findContours(opening, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cv2.findContours(opening, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]
for c in cnts:
x, y, w, h = cv2.boundingRect(c)
cv2.rectangle(image, (x, y), (x + w, y + h), (36, 255, 12), 3)
# filled
# cv2.rectangle(image, (x, y), (x + w, y + h), (36,255,12), -1)
# cv2.imwrite(path+'/test_ocr3/_stuff_OUT/'+'1_OUT.png', image)
cv2.imwrite(path+'/test_ocr3/_stuff_OUT/'+'page_1_0_TST_OUT.jpg', image)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Python-OpenCV
You can use Python-OpenCV like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
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