opencv-python

Stream OpenCV frame to HTML in Python

☆樱花仙子☆ 提交于 2020-07-31 09:01:52
问题 I am trying to read a video from a URL in opencv(Python) and then process it frame by frame and then send it to an HTML page. But I am only getting the first frame, after that the program gives the following error This is my main file ( main.py ) from flask import Flask, render_template, Response from camera import VideoCamera import pdb app = Flask(__name__) @app.route('/') def index(): return render_template('index.html') def gen(camera): while True: frame = camera.get_frame() yield (b'-

fastest way to find the rgb pixel color count of image

北慕城南 提交于 2020-07-30 21:32:21
问题 I have a use case where i have to find the consecutive rgb pixel color count of each frame of live video after searching i found a piece of code which does the same thing but performance wise it take around ~ 3 sec to give me output but in my case i have to do this calculation as fast as possible may be 25 frames in 1 seconds. Can someone help me to figure out how to do this by refactoring the below code from PIL import Image import timeit starttime = timeit.default_timer() with Image.open(

fastest way to find the rgb pixel color count of image

随声附和 提交于 2020-07-30 21:32:08
问题 I have a use case where i have to find the consecutive rgb pixel color count of each frame of live video after searching i found a piece of code which does the same thing but performance wise it take around ~ 3 sec to give me output but in my case i have to do this calculation as fast as possible may be 25 frames in 1 seconds. Can someone help me to figure out how to do this by refactoring the below code from PIL import Image import timeit starttime = timeit.default_timer() with Image.open(

Changing font family in OpenCV Python using PIL

笑着哭i 提交于 2020-07-21 03:54:48
问题 The above answer doesn't solve my problem. I am using cv2.putText() to put text over a video. This works as expected, but I am attempting to use a different font ( not available in OpenCV ). I understand that OpenCV is limited to the cv2.FONT_HERSHEY fonts, so I am using PIL with OpenCV to achieve this. I used this method with images and that experiment was successful. But I am failing when I try something similar on a video. import cv2 from PIL import ImageFont, ImageDraw, Image camera = cv2

Changing font family in OpenCV Python using PIL

夙愿已清 提交于 2020-07-21 03:54:05
问题 The above answer doesn't solve my problem. I am using cv2.putText() to put text over a video. This works as expected, but I am attempting to use a different font ( not available in OpenCV ). I understand that OpenCV is limited to the cv2.FONT_HERSHEY fonts, so I am using PIL with OpenCV to achieve this. I used this method with images and that experiment was successful. But I am failing when I try something similar on a video. import cv2 from PIL import ImageFont, ImageDraw, Image camera = cv2

How to join nearby bounding boxes in OpenCV Python

♀尐吖头ヾ 提交于 2020-06-11 05:23:06
问题 I am doing a college class project on image processing. This is my original image: I want to join nearby/overlapping bounding boxes on individual text line images, but I don't know how. My code looks like this so far (thanks to @HansHirse for the help): import os import cv2 import numpy as np from scipy import stats image = cv2.imread('example.png') gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) ret,thresh = cv2.threshold(gray,127,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU) #dilation kernel =

Detecting small squares attached to something else on the image

£可爱£侵袭症+ 提交于 2020-03-03 07:35:47
问题 I want to detect small squares circled in red on the image. But the problem is that they are on another white line. I want to know how to separate those squares from the white line and detect them. I have used OpenCV Python to write the code. What I have done until now is that I cropped the image so that I get access only to the circular part of the image. Then I cropped the image to get the required part that is the white line. Then I used erosion so that the white line will vanish and the

Detecting small squares attached to something else on the image

蓝咒 提交于 2020-03-03 07:35:05
问题 I want to detect small squares circled in red on the image. But the problem is that they are on another white line. I want to know how to separate those squares from the white line and detect them. I have used OpenCV Python to write the code. What I have done until now is that I cropped the image so that I get access only to the circular part of the image. Then I cropped the image to get the required part that is the white line. Then I used erosion so that the white line will vanish and the

Extract lined table from scanned document opencv python

冷暖自知 提交于 2020-02-23 02:54:30
问题 I want to extract the information from a scanned table and store it a csv. Right now my table extraction algorithm does the following steps. Apply skew correction Apply a gaussian filter for denoising. Do a binarization using Otsu thresholding Do a morphological opening. Canny egde detection Do a hough transform to obtain lines of table. Remove duplicate lines( same lines in the range of 10 pixels) filter the horizontal and vertical lines using slope of line(slope should be less than +/-5

Numpy + OpenCV-Python : Get coordinates of white pixels [duplicate]

断了今生、忘了曾经 提交于 2020-01-22 20:16:05
问题 This question already has answers here : Numpy binary matrix - get rows and columns of True elements (1 answer) Python: How to find the value of a number in a numpy array? (1 answer) Closed 2 years ago . I have a grayscale image and I want to get all the coordinates of pixels with intensity level 255. I tried using: pixels = np.where(img[img == 255]) But instead of getting a list of (X,Y) coordinates, I got a list of numbers, like if img was a one dimensional vector. What am I doing wrong? 来源