Tack, nu fungerade allt.
av 5
Re: 1 klicks program för att fota från wencam [Avslutat]
Re: 1 klicks program för att fota från wencam [Avslutat]
Så här blev koden efter jag testat den:
Grymt mycket tack till Knappas för denna kod!
Kod: Markera allt
#import numpy as np
import cv2
import time
import os
# Create a camera object-
camera_port = 0
camera = cv2.VideoCapture(camera_port)
# Set resolution of the image you want to capture, the capured image is as close as possible
# what the hardware can deliver.
width, height = 1280, 720
camera.set(cv2.CAP_PROP_FRAME_WIDTH, width)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
print "Model railrod stock camera version 1.0 by Knappas on Svenska ElektronikForumet "
print "made to lgrfbs on Svenska ElektronikForumet will be used on GMJ test track 2018"
print "------------------------------------------------------------------------------- "
print "Press [Space] to take a photo."
print "Press Q for quit/exit this program."
print "Photo folder:"+os.getcwd()
print "------------------------------------------------------------------------------- "
print " "
while(True):
# Capture frame-by-frame
ret, img = camera.read()
# Crop the image
#cx, cy, cw, ch = 100, 190, 1080, 340
Image_propositions=2
cx, cy, cw, ch = 100, 190, (230*Image_propositions), (80*Image_propositions)
cropped_img = img[cy:cy+ch, cx:cx+cw]
# Resize the cropped image, but you can use img instead if you want to resize the original.
rw, rh = 230, 80
resized_img = cv2.resize(cropped_img, (rw, rh))
# Display the full image with the cropped area marked with a green rectangle.
img = cv2.rectangle(img, (cx, cy), (cx + cw, cy + ch), (0,255,0), 2)
cv2.imshow('Video', img)
# Check for pressed keys
# <Space> = Take snapshoot
# q or ESC quits
key = cv2.waitKey(1) & 0xFF
if key == ord('q') or key == 27:
break
if key == ord(' '):
# Create a filename and save the cropped and resized image
filename = time.strftime("Picture%y%m%d %H%M%S.jpg", time.localtime())
print filename + " Taken!"
cv2.imwrite(filename, resized_img)
# When everything done, release the capture
camera.release()
cv2.destroyAllWindows()
print "Bye!"
Re: 1 klicks program för att fota från wencam [Avslutat]
Ingen orsak, kul att det fungerade
Och ett omnämnande också
Och ett omnämnande också
Re: 1 klicks program för att fota från wencam [Avslutat]
Så här blev det på första körning i rätta datorn (labbat på min laptop innan).
Får peta på lite positioner, men så när på en gång är ju rätt bra.Du har inte behörighet att öppna de filer som bifogats till detta inlägg.