小编GGz*_*zet的帖子

以不同的名称循环保存图像

我在循环保存裁剪的图像时遇到问题。我的代码:

def run(self, image_file):
    print(image_file)
    cap = cv2.VideoCapture(image_file)
    while(cap.isOpened()):
        ret, frame = cap.read()
        if ret == True:
            img = frame
            min_h = int(max(img.shape[0] / self.min_height_dec, self.min_height_thresh))
            min_w = int(max(img.shape[1] / self.min_width_dec, self.min_width_thresh))
            gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
            faces = self.face_cascade.detectMultiScale(gray, 1.3, minNeighbors=5, minSize=(min_h, min_w))

            images = []
            for i, (x, y, w, h) in enumerate(faces):
                images.append(self.sub_image('%s/%s-%d.jpg' % (self.tgtdir, self.basename, i + 1), img, x, y, w, h))
            print('%d faces detected' % len(images))

            for (x, y, w, h) in faces: 
                self.draw_rect(img, x, …
Run Code Online (Sandbox Code Playgroud)

python opencv

4
推荐指数
1
解决办法
2万
查看次数

How to resize frame's from video with aspect ratio

I am using Python 2.7, OpenCV. I have written this code.

import cv2
vidcap = cv2.VideoCapture('myvid2.mp4')
success,image = vidcap.read()
count = 0;
print "I am in success"
while success:
  success,image = vidcap.read()
  resize = cv2.resize(image, (640, 480)) 
  cv2.imwrite("%03d.jpg" % count, resize)     
  if cv2.waitKey(10) == 27:                     
      break
  count += 1
Run Code Online (Sandbox Code Playgroud)

I am working with video and am dividing the video into individual frames, as a .jpg images. I am also at the same time resizing the frames to dimension 640x480. The …

python video opencv resize image

0
推荐指数
1
解决办法
2万
查看次数

标签 统计

opencv ×2

python ×2

image ×1

resize ×1

video ×1