参看摄像头参数:
v4l2-ctl -d /dev/video0 --all
安装numpy:
sudo apt-get install python-numpy
下载onnx
pip install onnx
效果图:
拍照部分:
# url = 'http://192.168.1.108:8080/video'
i=0
# cap = cv2.VideoCapture(url)
cap = cv2.VideoCapture(0)
array_of_img = []
start = time.time()
directory_name=r'output1'
for i in range(10):
# Capture frame-by-frame
ret, frame = cap.read()
# Display the resulting frame
cv2.imshow('frame'+str(i),frame)
cv2.waitKey(0)
#time.sleep(10);
end = time.time()
cv2.imwrite('/home/heziyi/桌面/PyTorch-YOLOv3/data/custom/dd2/'+str(i)+".jpg",frame)
显示部分:
from __future__ import division
from models import *
from utils.utils import *
from utils.datasets import *
from utils.augmentations import *
from utils.transforms import *
import os
import sys
import time
import datetime
import argparse
from PIL import Image
import torch
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
from torchvision import datasets
from torch.autograd import Variable
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.ticker import NullLocator
import time
from time import strftime
import cv2
array_of_img = []
start = time.time()
i=0
directory_name=r'output1'
if __name__ == "__main__":
for filename in os.listdir(directory_name):
i=i+1
#print(filename) #just for test
#img is used to store the image data
img = cv2.imread(directory_name + "/" + filename)
array_of_img.append(img)
#print(img)
cv2.imshow(str(i),img)
cv2.waitKey(0)