I have a 1080p webcam (Logitech v-u0032) and I am creating program that saves still from it's feed every X seconds, however images have black bars on sides and resolution is seemingly lower than still taken with Windows built in camera app, both output file that has 1920x1080 pixels but difference in actual resolution is very visible
I've searched for ways to change the resolution but OpenCV seems to always upscale to new resolution
import cv2
import numpy as np
import datetime
import time
import os
cv2.namedWindow("Unregistered Hypercam")
vc = cv2.VideoCapture(0)
vc.set(3, 1920) # Set the horizontal resolution
vc.set(4, 1080) # Set the vertical resolution
vc.set(5, 10) # Set the framerate
if vc.isOpened():
rval, frame = vc.read()
else:
rval = False
lastSave = time.time()
def mfold(name):
try:
os.mkdir(name)
except OSError:
x = 0
else:
print ("Successfully created the directory %s " % fold)
while rval:
cv2.imshow("Unregistered Hypercam", frame)
rval, frame = vc.read()
now = datetime.datetime.now()
if time.time() > lastSave + 10:
lastSave = time.time()
fold = '\\snapshots\\' # This will create folder C:\snapshots
mfold(fold)
cv2.imwrite(fold + str(now.year) + '.' + str(now.month) + '.' + str(now.day) + ' ' + str(now.hour) + 'h_' + str(now.minute) + 'm_' + str(now.second) + 's.png', frame)
key = cv2.waitKey(20)
if key == 27:
break
cv2.destroyWindow("Unregistered Hypercam")
Images are blurry and unsharp with black bars and are nowhere similar to images taken with Windows camera app
