Horje
pppp Code Example
pppp
#!/usr/bin/python37
#Raspberry pi 3B/3B+, 4B, Buster, OpenCV 4.2.0
#Date: 5th April, 2020

import cv2 as cv
import numpy as np

img = cv.imread('organ1.jpg')
image_contours = np.zeros((img.shape[1],
                           img.shape[0], 1),
                          np.uint8)

image_binary = np.zeros((img.shape[1],
                         img.shape[0], 1),
                        np.uint8)

for channel in range(img.shape[2]):
    ret, image_thresh = cv.threshold(img[:, :, channel],
                                     38, 255,
                                     cv.THRESH_BINARY)

    contours = cv.findContours(image_thresh, 1, 1)[0]   
    cv.drawContours(image_contours,
                    contours, -1,
                    (255,255,255), 3)

contours = cv.findContours(image_contours, cv.RETR_LIST,
                           cv.CHAIN_APPROX_SIMPLE)[0]

cv.drawContours(image_binary, [max(contours, key = cv.contourArea)],
                -1, (255, 255, 255), -1)

cv.imwrite('LPR.jpg', image_binary)
cv.imshow('LPR', image_binary)
cv.waitKey(0) & 0xFF is 27
cv.destroyAllWindows()




Python

Related
vidgear python video streaming Code Example vidgear python video streaming Code Example
matplotlib bring plot to front in plots with twin axis Code Example matplotlib bring plot to front in plots with twin axis Code Example
Finding best model using GridSearchCV Code Example Finding best model using GridSearchCV Code Example
python sounddevice stop recording Code Example python sounddevice stop recording Code Example
Unicode decode error - 'utf-8' Code Example Unicode decode error - 'utf-8' Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6