Raspberry pi:convert fisheye image to normal image using python

2024/10/12 0:33:26

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"])

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'] = strToGPIO.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 directoryfp = open('image4.jpg', 'rb')msgImage = MIMEImage(fp.read())fp.close()msgRoot.attach(msgImage)# send mails = 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)

so how to add solution provided in this both link : https://github.com/kscottz/dewarp and http://www.kscottz.com/dewarped-panoramic-images-from-a-raspberrypi-camera-module/ in to my above code.

Answer

Maybe this could help :
http://www.kscottz.com/dewarped-panoramic-images-from-a-raspberrypi-camera-module/

this is the corresponding repo :
https://github.com/kscottz/dewarp

https://en.xdnf.cn/q/118264.html

Related Q&A

modifying python daemon script, stop does not return OK (but does kill the process)

Following on from the previous post, the script now start and stops the python script (and only that particular script) correctly but does not report the OK back to the screen...USER="root" A…

fulfill an empty dataframe with common index values from another Daframe

I have a daframe with a series of period 1 month and frequency one second.The problem the time step between records is not always 1 second.time c1 c2 2013-01-01 00:00:01 5 3 2013-01-0…

How to mix numpy slices to list of indices?

I have a numpy.array, called grid, with shape:grid.shape = [N, M_1, M_2, ..., M_N]The values of N, M_1, M_2, ..., M_N are known only after initialization.For this example, lets say N=3 and M_1 = 20, M_…

Visualize strengths and weaknesses of a sample from pre-trained model

Lets say Im trying to predict an apartment price. So, I have a lot of labeled data, where on each apartment I have features that could affect the price like:city street floor year built socioeconomic s…

Scrapy get result in shell but not in script

one topic again ^^ Based on recommendations here, Ive implemented my bot the following and tested it all in shell :name_list = response.css("h2.label.title::text").extract()packaging_list = r…

How to find a source when a website uses javascript

What I want to achieve I am trying to scrape the website below using Beautiful-soup and when I load the page it does not give the table that shows various quotes. In my previous posts folks have helped…

How to print a list of dicts as an aligned table?

So after going through multiple questions regarding the alignment using format specifiers I still cant figure out why the numerical data gets printed to stdout in a wavy fashion.def create_data(soup_ob…

abstract classes in python: Enforcing type

My question is related to this question Is enforcing an abstract method implementation unpythonic? . I am using abstract classes in python but I realize that there is nothing that stops the user from …

Convert image array to original svs format

Im trying to apply a foreground extraction to a SVS image (Whole Slide Image) usign OpenSlide library.First, I converted my image to an array to work on my foreground extraction:image = np.asarray(oslI…

Printing bytestring via variable

I have the following Unicode text stored in variable:myvariable = Gen\xe8veWhat I want to do is to print myvariable and show this:GenveI tried this but failed:print myvariable.decode(utf-8)Whats the ri…