예제 #1
0
def mplot(img, img2=none):

    cv2.namedwindow('img', cv2.window_normal)
    cv2.movewindow('img', 600, 300)
    cv2.imshow('img', img)
    if img2 is not none:
        cv2.namedwindow('img2', cv2.window_normal)
        cv2.movewindow('img', 600, 600)
        cv2.imshow('img2', img2)
    cv2.waitkey(0)
    cv2.destroyallwindows()
예제 #2
0
    def camera_detector(self, cap, wait=10):
        detect_timer = Timer()
        ret, _ = cap.read()

        while ret:
            ret, frame = cap.read()
            detect_timer.tic()
            result = self.detect(frame)
            detect_timer.toc()
            print('Average detecting time: {:.3f}s'.format(
                detect_timer.average_time))

            self.draw_result(frame, result)
            cv2.namedwindow('Camera',0)
            cv2.imshow('Camera', frame)
            cv2.waitKey(wait)

            ret, frame = cap.read()
예제 #3
0
    def preview(self, tl, wh):
        """
        Preview data in a pop up window live
        """
        import cv2
        self.action = "preview"
        logger.debug("Running preview of camera")
        try:
            for t_ms, frame in self._camera:
                cv2.namedwindow("preview")
                cv2.imshow("preview", frame)
                cv2.resizeWindow("preview", *wh)
                cv2.moveWindow("preview", *tl)
                if cv2.waitKey(10) & 0xFF == ord('q'):
                    break

        except KeyboardInterrupt:
            return 0

        return 0
예제 #4
0
#Need to work on it code for usb webcamera raspberry pi
import cv2
cam = cv2.VideoCapture(0)
img = cam.read()

cv2.namedwindow("camera", cv2.CV_WINDOW_AUTOSIZE)
cv2.imshow("camera", img)
cv2.waitKey(0)
cv2.destroywindow("camera")
#read image from file
img = cv2.imread(lena.bnp)
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
out=img.copy()
#get width and height
width, height = gray_img.shape[:2]

x=5
y=5
print(gray_image[x-1:x+2,y-1:y+2])
print(gray_image[x-1:x+2,y-1:y+2].sum())
print(int(gray_image[x-1:x+2,y-1:y+2].sum()/9)

for x in range(1, width-2):
      for y in range(1, height-2):
          out[x,y] = int(gray_image[x-1:x+2,y-1:y+2].sum()/9)
      
for x in range(1, width-2):
      for y in range(1, height-2):
          out2[x,y] = np.median(gray_image[x-1:x+2,y-1:y+2])

#display image
      cv2.namedwindow('Mean', cv2.WINDOW_NORMAL)
      cv2.imshow('Mean',out)
#display image
      cv2.namedwindow('Median', cv2.WINDOW_NORMAL)
      cv2.imshow('Median',out)
      cv2.waitKey(0)    #waits for any keyboard event
      
예제 #6
0
 def createwindow(self):
     cv2.namedwindow(self.windowname)
     self.iswindowcreated = True