image-processing

Drawing a line on an image using mouse clicks with Python OpenCV library

五迷三道 提交于 2020-05-30 08:29:25
问题 I am trying to draw a line on an image using mouse operations. I am using OpenCV library. My code import matplotlib.pyplot as plt import cv2 src_window = 'CV2 Window' SHOW_DEBUG_STEPS = True drag = 0 select_flag = 0 x1 = 0 x2 = 0 y1 = 0 y2 = 0 point1 = [x1,y1] point2 = [x2,y2] SCALAR_YELLOW = (0.0,255.0,255.0) cap = cv2.VideoCapture('example_01.mp4') def closeAll(): cap.release() cv2.destroyAllWindows() def retn(ret): if not ret: print('Error reading the frame') closeAll() def frm(fFrame): if

Crop and resize image around a custom focus point

北城余情 提交于 2020-05-30 08:12:43
问题 The story An overview of what I want to accomplish: I have photos that need to be cropped and resized, once for a thumbnail view (around 295x195), and once for a "header-image" style view (around 1400x560). The original photos vary in size, the biggest are around 2440x1600. This would not be a problem to solve. However, the image should not be cropped with a "North" or "Center" gravity but should have a defined center position from where the image should be cropped. For this, an image has x

Is it possible to create a video stream (mpeg or mjpeg) from jpeg images that are continuously created?

你说的曾经没有我的故事 提交于 2020-05-30 08:01:35
问题 I need to create a screen grab video stream of the display low powered embedded device. It does not have the capacity to run a desktop sharing service live VNC. But it can give 2-3 screenshots every second through an API to a separate HTTP client running elsewhere. Is there a way I can create a video stream from the images retrieved by running the Screenshot API continuously. 回答1: You can use ffmpeg to create a real time video stream using continues jpeg files and it will create mpeg format

How to find endpoints of lines in OpenCV?

别说谁变了你拦得住时间么 提交于 2020-05-29 04:30:27
问题 I have an image made up of lines; how can I find the endpoints with OpenCV? The lines are about 20 pixels wide. They turn, branch, and can be at angles (although mostly horizontal and vertical). Note that Hough won't work because my lines aren't straight. (Maybe that makes them contours?) I looked at this answer but it finds extreme points, not endpoints. I looked at this, but I think goodFeaturesToTrack() will pick up corners too. Maybe use a thinning algorithm, although OpenCV doesn't seem

How to Change image captured date in python?

前提是你 提交于 2020-05-28 14:04:51
问题 I have over 500 images (png /jpg) having wrong captured date (Date taken) because of wrong camera date settings. I moved photos to mobile and mobile gallery sorts photos on the basis of 'Date Taken'. I want all photos to be displayed in order. So how can I change captured date (Date taken) using python script? 回答1: No real need to write Python, you can do it in one line in the Terminal using jhead . For example, adjust all EXIF times forward by 1 hour jhead -ta+1:00 *.jpg Make a COPY of your

How to Change image captured date in python?

一笑奈何 提交于 2020-05-28 14:03:33
问题 I have over 500 images (png /jpg) having wrong captured date (Date taken) because of wrong camera date settings. I moved photos to mobile and mobile gallery sorts photos on the basis of 'Date Taken'. I want all photos to be displayed in order. So how can I change captured date (Date taken) using python script? 回答1: No real need to write Python, you can do it in one line in the Terminal using jhead . For example, adjust all EXIF times forward by 1 hour jhead -ta+1:00 *.jpg Make a COPY of your

android: smooth out edges of random shape bitmap

大兔子大兔子 提交于 2020-05-28 09:25:40
问题 I have an random shape bitmap cut out by user. I want to fade out its borders i.e. contours, so as to make it appear smooth. What should I do? To get the borders and color of every pixel in bitmap, I am traversing it pixel by pixel. It takes long time, still I am ok with it. Is openCV my only option? If yes, can anybody point me towards any tutorial or suggestion for logical approach? 回答1: You can just run a smoothing filter on your shape. In opencv you can use the blur fnnction or

How to find the orientation of an object (shape)? - Python Opencv

送分小仙女□ 提交于 2020-05-28 05:48:30
问题 My images are always like this: But I need to rotate them to be like this: But to do that, I need to find the orientation of the object, knowing that the thinner part of the object has to be on the left side. In summary, the images are wings and the start of the wing has to be on the left side and the end of the wing has to be on the right side. I hope someone can give me a suggestion, I've tried a bunch of different strategies but with no good result so far. 回答1: Here is one way in Python

Opencv Detect boundary and ROI mask

梦想的初衷 提交于 2020-05-27 16:59:40
问题 Hi , I have attached the image below with an yellow bounding box. Is there any algorithm or (sequence of algorithms) in Opencv by which I can detect the yellow pixels and create a ROI mask (which will block out all the pixels outside of it). 回答1: You can do: Find the yellow polygon Fill the inside of the polygon Copy only the inside of the polygon to a black-initialized image Find the yellow polygon Unfortunately, you used anti-aliasing to draw the yellow line, so the yellow color is not pure

How to clear circle in CGContext in iOS

倾然丶 夕夏残阳落幕 提交于 2020-05-26 09:09:51
问题 I want create image using CGcontext. This is simple image with white or black background. also I want to add transperent part which is in circle ( check attached image). I know how to do this in rect. But i want to make it circle. Please anyone help me in this. 回答1: Use the below code to clear circle in your context -(UIImage *) getImageWithcenterClear:(CGPoint) center{ CGRect frame = [[UIScreen mainScreen] bounds]; UIGraphicsBeginImageContextWithOptions([[UIScreen mainScreen] bounds].size,