27 lines
786 B
Python
27 lines
786 B
Python
import cv2
|
|
import numpy as np
|
|
import os
|
|
import time
|
|
import requests
|
|
|
|
def image_cropp(images: list, crop_params):
|
|
top = crop_params.get('top', 0)
|
|
bottom = crop_params.get('bottom', 0)
|
|
left = crop_params.get('left', 0)
|
|
right = crop_params.get('right', 0)
|
|
new_images = []
|
|
for image in images:
|
|
if (top + bottom >= image.shape[0]) or (left + right >= image.shape[1]) \
|
|
or image is None:
|
|
new_images.append(image)
|
|
|
|
new_images.append(image[top:image.shape[0] - bottom, left:image.shape[1] - right])
|
|
return new_images
|
|
|
|
def frame_show(image):
|
|
if image is not None:
|
|
frame = cv2.resize(image, (320, 320))
|
|
cv2.imshow('main', frame)
|
|
if cv2.waitKey(1) & 0xFF == ord('q'):
|
|
quit()
|