def eval_score(self): """ Evaluate the focus score """ for i in self.img: # a = dwt.nleveldwt(3,i) # self.score.append(-1*dwt.focus_score(a)) self.score.append(-1 * dwt.focus_score(i)) return self
def eval_score(self): """ Evaluate the focus score """ for i in self.img: # a = dwt.nleveldwt(3,i) # self.score.append(-1*dwt.focus_score(a)) self.score.append(-1*dwt.focus_score(i)) return self
def focus(self): """ Return focus score """ #return -1*dwt.focus_score(self.get_image()) #a = dwt.nleveldwt(3,self.get_image()) #return -1*dwt.focus_score(a) return -1 * dwt.focus_score(self.get_image())
import os import picamera import picamera.array import cv2 import time import numpy as np import dwt while(1): with picamera.PiCamera() as camera: camera.start_preview() time.sleep(0.1) with picamera.array.PiRGBArray(camera) as stream: camera.capture(stream, format = 'bgr') image = cv2.cvtColor(stream.array, cv2.COLOR_BGR2GRAY) Y = dwt.nleveldwt(3,image) print(dwt.focus_score(Ys[1:]))
def focus(self): """ Return focus score """ #return -1*dwt.focus_score(self.get_image()) #a = dwt.nleveldwt(3,self.get_image()) #return -1*dwt.focus_score(a) return -1*dwt.focus_score(self.get_image())