OpenCV

Image segmentation in python

雨燕双飞 提交于 2021-02-07 08:00:33
问题 I have the image I am looking for python solution to break the shape in this image into smaller parts according to the contour in the image. I have looked into solution on Canny and findContours in OpenCV but none of them works for me. Edit: Code used: using Canny method import cv2 import numpy as np img = cv2.imread('area_of_blob_maxcontrast_white.jpg') edges = cv2.Canny(img, 100, 200) cv2.imwrite('area_of_blob_maxcontrast_white_edges.jpg',edges) using findContours method import numpy as np

Image segmentation in python

会有一股神秘感。 提交于 2021-02-07 07:59:40
问题 I have the image I am looking for python solution to break the shape in this image into smaller parts according to the contour in the image. I have looked into solution on Canny and findContours in OpenCV but none of them works for me. Edit: Code used: using Canny method import cv2 import numpy as np img = cv2.imread('area_of_blob_maxcontrast_white.jpg') edges = cv2.Canny(img, 100, 200) cv2.imwrite('area_of_blob_maxcontrast_white_edges.jpg',edges) using findContours method import numpy as np

Image segmentation in python

别说谁变了你拦得住时间么 提交于 2021-02-07 07:56:14
问题 I have the image I am looking for python solution to break the shape in this image into smaller parts according to the contour in the image. I have looked into solution on Canny and findContours in OpenCV but none of them works for me. Edit: Code used: using Canny method import cv2 import numpy as np img = cv2.imread('area_of_blob_maxcontrast_white.jpg') edges = cv2.Canny(img, 100, 200) cv2.imwrite('area_of_blob_maxcontrast_white_edges.jpg',edges) using findContours method import numpy as np

How to Reduce the Resolution of an Image in OpenCV?

北城以北 提交于 2021-02-07 07:53:45
问题 So, I have an image from a digital scanner, its resolution is 26 Megapixel. I want to reduce the resolution of the image to 5 Megapixel. Is it possible to reduce the resolution of an image without damaging the contents? If yes, how to reduce it in OpenCV implementation? Any help would be greatly appreciated. Thankyou 回答1: You can use cv2::resize() resize(src, dst, Size(), factor, factor, interpolation); here, interpolation can be selected as cv::INTER_LANCZOS4 to obtain best interpolation

How to open an image from an url with opencv using requests from python

我与影子孤独终老i 提交于 2021-02-07 07:52:44
问题 I am trying to open a large list of images using OpenCV on python, because I need to work with them latter. Actually, I can achieve this goal with pillow like this: url = r'https://i.imgur.com/DrjBucJ.png' response = requests.get(url, stream=True).raw guess = Image.open(response).resize(size) I am using the library requests from python. The response looks like this: b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x01\xdb\... And if I am not wrong, those are the values of the pixels from the

OpenCV : wrapPerspective on whole image

自古美人都是妖i 提交于 2021-02-07 07:18:03
问题 I'm detecting markers on images captured by my iPad. Because of that I want to calculate translations and rotations between them, I want to change change perspective on images these image, so it would look like I'm capturing them directly above markers. Right now I'm using points2D.push_back(cv::Point2f(0, 0)); points2D.push_back(cv::Point2f(50, 0)); points2D.push_back(cv::Point2f(50, 50)); points2D.push_back(cv::Point2f(0, 50)); Mat perspectiveMat = cv::getPerspectiveTransform(points2D,

OpenCV : wrapPerspective on whole image

六月ゝ 毕业季﹏ 提交于 2021-02-07 07:14:35
问题 I'm detecting markers on images captured by my iPad. Because of that I want to calculate translations and rotations between them, I want to change change perspective on images these image, so it would look like I'm capturing them directly above markers. Right now I'm using points2D.push_back(cv::Point2f(0, 0)); points2D.push_back(cv::Point2f(50, 0)); points2D.push_back(cv::Point2f(50, 50)); points2D.push_back(cv::Point2f(0, 50)); Mat perspectiveMat = cv::getPerspectiveTransform(points2D,

OpenCV : wrapPerspective on whole image

妖精的绣舞 提交于 2021-02-07 07:12:02
问题 I'm detecting markers on images captured by my iPad. Because of that I want to calculate translations and rotations between them, I want to change change perspective on images these image, so it would look like I'm capturing them directly above markers. Right now I'm using points2D.push_back(cv::Point2f(0, 0)); points2D.push_back(cv::Point2f(50, 0)); points2D.push_back(cv::Point2f(50, 50)); points2D.push_back(cv::Point2f(0, 50)); Mat perspectiveMat = cv::getPerspectiveTransform(points2D,

How to resize frame's from video with aspect ratio

六眼飞鱼酱① 提交于 2021-02-07 06:55:52
问题 I am using Python 2.7, OpenCV. I have written this code. import cv2 vidcap = cv2.VideoCapture('myvid2.mp4') success,image = vidcap.read() count = 0; print "I am in success" while success: success,image = vidcap.read() resize = cv2.resize(image, (640, 480)) cv2.imwrite("%03d.jpg" % count, resize) if cv2.waitKey(10) == 27: break count += 1 I am working with video and am dividing the video into individual frames, as a .jpg images. I am also at the same time resizing the frames to dimension

pkg-config can't find opencv

一笑奈何 提交于 2021-02-07 06:24:56
问题 I installed opencv on a lubuntu 12.10 distro. Then when I try to compile a code which is using opencv it says it can't find it. So I try in a terminal : pkg-config --cflags --libs opencv It answers me that it can't find opencv. But the files are installed in /usr/lib. I don't understand why it can't find them. 回答1: You have to put pkg-config --cflags --libs opencv at the end of your g++ line. For example : g++ test.cpp -o test `pkg-config --cflags --libs opencv` Compiles g++ `pkg-config -