cv2

How to crop the biggest object in image with python opencv?

为君一笑 提交于 2020-01-12 08:30:32
问题 I want to crop the biggest object in the image (Characters). This code only works if there is no line (shown in the first image). But I need to ignore the line and make the image of the second image. Only crop the biggest object image. import cv2 x1, y1, w1, h1 = (0,0,0,0) points = 0 # load image img = cv2.imread('Image.jpg') gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # convert to grayscale # threshold to get just the signature retval, thresh_gray = cv2.threshold(gray, thresh=100, maxval

getting error while importing cv2 module in ubuntu amazon instance

旧巷老猫 提交于 2020-01-06 05:50:06
问题 getting error while doing this import cv2 python3: Relink `/lib/x86_64-linux-gnu/libudev.so.1' with `/lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol `clock_gettime' Segmentation fault (core dumped) import cv2 python3: Relink `/lib/x86_64-linux-gnu/libudev.so.1' with `/lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol `clock_gettime' Segmentation fault (core dumped) 回答1: perhaps CUDA was not installed properly check it 来源: https://stackoverflow.com/questions/56347458/getting-error-while

removing background 'noise' from signal images (RGB)

梦想与她 提交于 2020-01-06 05:37:26
问题 I have some signal images: As you can inspect, some of them contain color signals and some are just gray/black color signals. My task is to extract pure signal with white background only. That means I need to remove all but signal in the image. I checked that dash lines, dotted lines, solid lines (top and bottom) have the same RGB value that are close to 0;0;0 (ex: 0;0;0, 2;2;2; or 8;8;8) in terms of RGB. Therefore, first thing that came to my mind was to access RGB values of each pixel and

Out of memory converting image files to numpy array

十年热恋 提交于 2020-01-06 05:11:16
问题 I'm trying to run a loop that iterates through an image folder and returns two numpy arrays: x - stores the image as a numpy array y - stores the label. A folder can easily have over 40.000 rgb images, with dimensions (224,224). I have around 12Gb of memory but after some iterations, the used memory just spikes up and everything stops. What can I do to fix this issue? def create_set(path, quality): x_file = glob.glob(path + '*') x = [] for i, img in enumerate(x_file): image = cv2.imread(img,

cv2 image show doesn't work when multithreading

久未见 提交于 2020-01-06 03:13:05
问题 I am trying to put images on screen while capturing webcam (I'm using MAC). Hence, I started two thread: one for capturing video, the other for presenting images on screen: webcam_thread = self.init_webcam_thread() images_thread = self.init_images_thread() webcam_thread.start() images_thread.start() The video capture is working correctly; The image show is working correctly while I'm not using thread (When this is the only process). However, when using mutli-Threading, all presented in a

Python OpenCV cv2 - Easy way to increase the brightness and contrast of an image by 100%

不打扰是莪最后的温柔 提交于 2020-01-05 11:09:10
问题 i want to change the both brightness and contrast of an existing image by 100%. decoded = Image.open(BytesIO(base64.b64decode(base64Data))) image = cv2.cvtColor(np.array(decoded), cv2.COLOR_BGR2RGB) Is there a function that allows me to do this? 回答1: I couldn't find OpenCV function for this, but I found that guide: https://docs.opencv.org/3.4/d3/dc1/tutorial_basic_linear_transform.html It says that you can adjust contrast and brightness this way: new_image = old_image * contrast_coeff +

Python OpenCV cv2 - Easy way to increase the brightness and contrast of an image by 100%

只谈情不闲聊 提交于 2020-01-05 11:08:13
问题 i want to change the both brightness and contrast of an existing image by 100%. decoded = Image.open(BytesIO(base64.b64decode(base64Data))) image = cv2.cvtColor(np.array(decoded), cv2.COLOR_BGR2RGB) Is there a function that allows me to do this? 回答1: I couldn't find OpenCV function for this, but I found that guide: https://docs.opencv.org/3.4/d3/dc1/tutorial_basic_linear_transform.html It says that you can adjust contrast and brightness this way: new_image = old_image * contrast_coeff +

Resizing an input image in a Keras Lambda layer

风流意气都作罢 提交于 2019-12-28 13:08:06
问题 I would like my keras model to resize the input image using cv2 or similar. I have seen the use of ImageGenerator , but I would prefer to write my own generator and simply resize the image in the first layer with keras.layers.core.Lambda . How would I do this? 回答1: If you are using tensorflow backend then you can use tf.image.resize_images() function to resize the images in Lambda layer. Here is a small example to demonstrate the same: import numpy as np import scipy.ndimage import matplotlib

Unable to write text on mouseclick area on Image

雨燕双飞 提交于 2019-12-25 18:33:47
问题 I am trying to draw text on Image where the user clicks. Getting this error: Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\Admin\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "C:/Users/Admin/PycharmProjects/ashish/td.py", line 35, in draw_text cv2.putText(img, "OpenCV + Jurassic Park!!!", (event.x,event.y), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 255, 0), 2) TypeError: Expected cv::UMat for

odd image using cv2 and numpy

℡╲_俬逩灬. 提交于 2019-12-25 02:13:42
问题 I am running the following code: import cv2 import numpy f = open("raw_image",'rb') raw_image = f.read(720 * 1280 * 3) image = numpy.fromstring(raw_image, dtype='uint8') image = image.reshape((720, 1280, 3)) cv2.imshow('Image', image) cv2.waitKey(0) cv2.destroyAllWindows() cv2.waitKey(1) and I get this result: the image is RGB image with height of 720p and width of 1280. Any Ideas how to solve it? EDIT : I receive images from a camera with resolution of 720x1280. The image is a colored image.