问题描述
我已经连接USB网络摄像头与树莓pi捕获图像和编写代码,使用邮件发送。它使用 fswebcam
commamnd捕获图像,因此在python脚本中捕获图像的代码是:
I have attached the USB webcam with raspberry pi to capture image and write code to send it using mail. It captures image using fswebcam
commamnd so code for capture image in python script is :
subprocess.Popen(["fswebcam","-r 640x480", "image4.jpg"])
$ b b
当我从树莓派切换,它捕获图像并发送它使用邮件,但问题是捕获的图像是鱼眼图像和iIwant将这个鱼眼图像转换为正常图像,但我不知道它的命令,任何代码转换成普通图像使用python在树莓pi?谢谢这是我的代码:
when I pressed switch from raspberry pi it capture image and sends it using mail,but problem is that captured image is fisheye image and iIwant to convert this fisheye image into normal image but I don't know the command for it or any code to convert it into normal image using python in raspberry pi? Thanks.This is my code:
import smtplib
import time
import subprocess
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.MIMEImage import MIMEImage
import RPi.GPIO as GPIO
# Define these once; use them twice!
strFrom = '[email protected]'
strTo = '[email protected]'
#create email
# Create the root message and fill in the from, to, and subj$
msgRoot = MIMEMultipart()
msgRoot['Subject'] = 'capture image'
msgRoot['From'] = strFrom
msgRoot['To'] = strTo
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN)
print "press button to send email"
GPIO.setup(4,GPIO.IN,pull_up_down=GPIO.PUD_UP)
while True:
input=GPIO.input(4)
if input == False:
print "button pressed"
subprocess.Popen(["fswebcam","-r 640x480", "image4.jpg"])
time.sleep(5)
# This example assumes the image is in the current directory
fp = open('image4.jpg', 'rb')
msgImage = MIMEImage(fp.read())
fp.close()
msgRoot.attach(msgImage)
# send mail
s = smtplib.SMTP('smtp.gmail.com',587)
s.starttls()
s.login('[email protected]' , 'password')
s.sendmail(strFrom, strTo, msgRoot.as_string())
s.close()
print "Email sent"
time.sleep(0.2)
,因此如何添加此链接中提供的解决方案:和到我上面的代码。
推荐答案
也许这有助于:
这是相应的回购:
这篇关于树莓pi:使用python将鱼眼图像转换为正常图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!