Error: (-215:Assertion failed) npoints > 0 while working with contours using OpenCV

Issue When I run this code: import cv2 image = cv2.imread(‘screenshoot10.jpg’) cv2.imshow(‘input image’, image) gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) edged = cv2.Canny(gray, 30, 200) cv2.imshow(‘canny edges’, edged) _, contours = cv2.findContours(edged, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) cv2.imshow(‘canny edges after contouring’, edged) print(contours) print(‘Numbers of

Continue reading

What purpose does .astype("uint8") have here?

Issue (score,diff)= structural_similarity(original_gray,tempered_gray,full=True) diff = (diff*255).astype("uint8") print("SSIM:{}".format(score)) The above mentioned code is a snippet from a program that matches two images using their SSIM score. What I don’t understand here is the function of .astype("uint8"), and why are we multiplying

Continue reading

Removing Horizontal Lines in image (OpenCV, Python, Matplotlib)

Issue Using the following code I can remove horizontal lines in images. See result below. import cv2 from matplotlib import pyplot as plt img = cv2.imread(‘image.png’,0) laplacian = cv2.Laplacian(img,cv2.CV_64F) sobelx = cv2.Sobel(img,cv2.CV_64F,1,0,ksize=5) plt.subplot(2,2,1),plt.imshow(img,cmap = ‘gray’) plt.title(‘Original’), plt.xticks([]), plt.yticks([]) plt.subplot(2,2,2),plt.imshow(laplacian,cmap =

Continue reading

Find near duplicate and faked images

Issue I am using Perceptual hashing technique to find near-duplicate and exact-duplicate images. The code is working perfectly for finding exact-duplicate images. However, finding near-duplicate and slightly modified images seems to be difficult. As the difference score between their hashing

Continue reading

Remove all but specific part of image

Issue I am using Python face-recognition library to detect faces in an image, it returnes coordenates of faces in the image. i would like to delete all but the coordenates returned by the face-recognition function import face_recognition image1 = face_recognition.load_image_file("image

Continue reading