Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将参数附加到subprocess.call()中_Python_Linux_Raspberry Pi_Debian_Raspbian - Fatal编程技术网

Python 将参数附加到subprocess.call()中

Python 将参数附加到subprocess.call()中,python,linux,raspberry-pi,debian,raspbian,Python,Linux,Raspberry Pi,Debian,Raspbian,我试图通过Python在我的Raspberry Pi上运行命令,使用带有subprocess.call命令的Raspbian。具体地说,我正试图用它拍摄一张相机的照片,这只是为了记录,因为我可以使用raspistill并获得所需的输出 以下是我的python代码: #PROCEDURE TO TAKE PHOTO WITH DEFAULT CAMERA ON RASPBERRY PI import subprocess def pyraspistill(name): subprocess

我试图通过Python在我的Raspberry Pi上运行命令,使用带有subprocess.call命令的Raspbian。具体地说,我正试图用它拍摄一张相机的照片,这只是为了记录,因为我可以使用raspistill并获得所需的输出

以下是我的python代码:

#PROCEDURE TO TAKE PHOTO WITH DEFAULT CAMERA ON RASPBERRY PI
import subprocess
def pyraspistill(name):
    subprocess.call(['/usr/bin/raspistill','-o',name + ".jpg"], shell=True)
pyraspistill("name")
但是,它没有使用给定的参数拍摄照片,只是列出了有关raspistill命令的信息。为什么?我如何避免这种情况

作为参考,以下是它返回的内容(不,它也不会给出图像):

george@raspberrypi:~$sudo python camera.py
raspistill相机应用程序v1.3.11
在特定时间运行相机,并在需要时在结束时拍摄JPG
用法:raspistill[选项]
图像参数命令
-?,--帮助:此帮助信息
-w、 --宽度:设置图像宽度
-h、 --高度:设置图像高度
-q、 --质量:设置jpeg质量
-r、 --原始:将原始拜耳数据添加到jpeg元数据
-o、 --输出:输出文件名(要写入标准输出,请使用“-o-”)。如果未指定,则不保存任何文件
-l、 --最新:将最新的完整图像链接到文件名
-v、 --详细:在运行期间输出详细信息
-t、 --超时:拍照和关机前的时间(毫秒)(如果未指定,则设置为5s)
-th,--thumb:设置缩略图参数(x:y:quality)或无
-d、 --演示:运行演示模式(在相机选项范围内循环,无拍摄)
-e、 --编码:用于输出文件的编码(jpg、bmp、gif、png)
-x、 --exif:exif标记应用于捕获(格式为“key=value”)或无
-tl,--timelapse:timelapse模式。每毫秒拍一张照片。%d==帧号(Try:-o img_U04d.jpg)
-fp,--fullpreview:使用静止捕获分辨率运行预览(可能会减少预览fps)
-k、 --按键:在两次捕获之间等待回车,然后回车退出
-s、 --信号:在从另一个进程捕获SIGUSR1或SIGUSR2之间等待
-g、 --gl:将预览绘制到纹理,而不是使用视频渲染组件
-gc,--glcapture:捕获GL帧缓冲区而不是相机图像
-设置,-settings:检索相机设置并写入标准输出
-cs,--camselect:选择相机。默认值0
-bm,--突发:启用“突发捕获模式”
-md,--模式:力传感器模式。0=自动。其他可用模式见文档
-dt,--datetime:将输出模式(%d)替换为datetime(MonthDayHourMinSec)
-ts,--timestamp:将输出模式(%d)替换为unix时间戳(自1970年以来的秒数)
-fs,--framestart:输出模式(%d)中的起始帧编号
-rs,--restart:JPEG重新启动间隔(默认为0表示无)
-gps,--gpsdexif:将来自gpsd的实时gps信息作为EXIF标记应用(需要libgps.so.22)
预览参数命令
-p、 --预览:预览窗口设置
-f、 --全屏:全屏预览模式
-op,--不透明度:预览窗口不透明度(0-255)
-n、 --nopreview:不显示预览窗口
图像参数命令
-sh,--清晰度:设置图像清晰度(-100到100)
-co,--对比度:设置图像对比度(-100到100)
-br,--亮度:设置图像亮度(0到100)
-sa,--饱和度:设置图像饱和度(-100到100)
-ISO,--ISO:设置捕获ISO
-vs,--vstab:打开视频稳定
-ev,--ev:设置ev补偿-1/6步停止
-ex,--曝光:设置曝光模式(见注释)
-fli,--闪烁:设置闪烁避免模式(参见注释)
-awb,--awb:设置awb模式(参见注释)
-ifx,--imxfx:设置图像效果(请参见注释)
-cfx,--colfx:设置颜色效果(U:V)
-mm,--计量:设置计量模式(见注释)
-旋转,--旋转:设置图像旋转(0-359)
-hf,--hflip:设置水平翻转
-vf,--vflip:设置垂直翻转
-roi,--roi:设置感兴趣区域(x、y、w、d作为标准化坐标[0.0-1.0])
-ss,--快门:以微秒为单位设置快门速度
-awbg,--awbgains:设置AWB增益-AWB模式必须关闭
-drc,--drc:设置drc级别(见注释)
-st,--stats:强制重新计算静物捕捉通行证的统计信息
-a、 --注释:启用/设置注释标志或文本
-3d,--立体:选择立体模式
-dec,--抽取:立体图像的半宽/半高
-3dswap,--3dswap:交换立体相机顺序
-ae,--AnnotateX:设置额外的注释参数(文本大小、文本颜色(十六进制YUV)、背景颜色(十六进制YUV)、对齐、x、y)
-ag,--analoggain:设置模拟增益(浮点)
-dg,--数字增益:设置数字增益(浮点)
笔记
曝光模式选项:
关闭、自动、夜间、夜间预览、背光、聚光灯、运动、降雪、海滩、维隆、固定FPS、防抖、焰火
闪烁避免模式选项:
关闭,自动,50hz,60hz
AWB模式选项:
关闭、自动、太阳、云、阴影、钨、荧光灯、白炽灯、闪光灯、地平线
图像效果模式选项:
无、负片、日光浴、素描、去噪、浮雕、油画、图案填充、gpen、粉彩、水彩、胶片、模糊、饱和度、调色、水洗、后处理、色点、色彩平衡、卡通
计量模式选项:
平均值、光斑、背光、矩阵
动态范围压缩(DRC)选项:
关、低、中、高
预览参数命令
-gs,--glscene:GL场景广场、茶壶、镜子、yuv、sobel、vcsm_广场
-gw,--glwin:GL窗口设置
在这里输入代码
回答:

不要使用shell=True,因为只有第一项会传递给命令,其他参数会作为参数传递给shell-@juanpa.arrivillaga


多谢各位。我添加这个作为结束问题的答案,因为它是一个注释:)

不要使用
shell=True
,因为只有第一项会传递给命令,其他参数会作为参数传递给shell
george@raspberrypi:~ $ sudo python camera.py

raspistill Camera App v1.3.11

Runs camera for specific time, and take JPG capture at end if requested

usage: raspistill [options]

Image parameter commands

-?, --help      : This help information
-w, --width     : Set image width <size>
-h, --height    : Set image height <size>
-q, --quality   : Set jpeg quality <0 to 100>
-r, --raw       : Add raw bayer data to jpeg metadata
-o, --output    : Output filename <filename> (to write to stdout, use '-o -'). If not specified, no file is saved
-l, --latest    : Link latest complete image to filename <filename>
-v, --verbose   : Output verbose information during run
-t, --timeout   : Time (in ms) before takes picture and shuts down (if not specified, set to 5s)
-th, --thumb    : Set thumbnail parameters (x:y:quality) or none
-d, --demo      : Run a demo mode (cycle through range of camera options, no capture)
-e, --encoding  : Encoding to use for output file (jpg, bmp, gif, png)
-x, --exif      : EXIF tag to apply to captures (format as 'key=value') or none
-tl, --timelapse        : Timelapse mode. Takes a picture every <t>ms. %d == frame number (Try: -o img_%04d.jpg)
-fp, --fullpreview      : Run the preview using the still capture resolution (may reduce preview fps)
-k, --keypress  : Wait between captures for a ENTER, X then ENTER to exit
-s, --signal    : Wait between captures for a SIGUSR1 or SIGUSR2 from another process
-g, --gl        : Draw preview to texture instead of using video render component
-gc, --glcapture        : Capture the GL frame-buffer instead of the camera image
-set, --settings        : Retrieve camera settings and write to stdout
-cs, --camselect        : Select camera <number>. Default 0
-bm, --burst    : Enable 'burst capture mode'
-md, --mode     : Force sensor mode. 0=auto. See docs for other modes available
-dt, --datetime : Replace output pattern (%d) with DateTime (MonthDayHourMinSec)
-ts, --timestamp        : Replace output pattern (%d) with unix timestamp (seconds since 1970)
-fs, --framestart       : Starting frame number in output pattern(%d)
-rs, --restart  : JPEG Restart interval (default of 0 for none)
-gps, --gpsdexif        : Apply real-time GPS information from gpsd as EXIF tags (requires libgps.so.22)

Preview parameter commands

-p, --preview   : Preview window settings <'x,y,w,h'>
-f, --fullscreen        : Fullscreen preview mode
-op, --opacity  : Preview window opacity (0-255)
-n, --nopreview : Do not display a preview window

Image parameter commands

-sh, --sharpness        : Set image sharpness (-100 to 100)
-co, --contrast : Set image contrast (-100 to 100)
-br, --brightness       : Set image brightness (0 to 100)
-sa, --saturation       : Set image saturation (-100 to 100)
-ISO, --ISO     : Set capture ISO
-vs, --vstab    : Turn on video stabilisation
-ev, --ev       : Set EV compensation - steps of 1/6 stop
-ex, --exposure : Set exposure mode (see Notes)
-fli, --flicker : Set flicker avoid mode (see Notes)
-awb, --awb     : Set AWB mode (see Notes)
-ifx, --imxfx   : Set image effect (see Notes)
-cfx, --colfx   : Set colour effect (U:V)
-mm, --metering : Set metering mode (see Notes)
-rot, --rotation        : Set image rotation (0-359)
-hf, --hflip    : Set horizontal flip
-vf, --vflip    : Set vertical flip
-roi, --roi     : Set region of interest (x,y,w,d as normalised coordinates [0.0-1.0])
-ss, --shutter  : Set shutter speed in microseconds
-awbg, --awbgains       : Set AWB gains - AWB mode must be off
-drc, --drc     : Set DRC Level (see Notes)
-st, --stats    : Force recomputation of statistics on stills capture pass
-a, --annotate  : Enable/Set annotate flags or text
-3d, --stereo   : Select stereoscopic mode
-dec, --decimate        : Half width/height of stereo image
-3dswap, --3dswap       : Swap camera order for stereoscopic
-ae, --annotateex       : Set extra annotation parameters (text size, text colour(hex YUV), bg colour(hex YUV), justify, x, y)
-ag, --analoggain       : Set the analog gain (floating point)
-dg, --digitalgain      : Set the digital gain (floating point)


Notes

Exposure mode options :
off,auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks

Flicker avoid mode options :
off,auto,50hz,60hz

AWB mode options :
off,auto,sun,cloud,shade,tungsten,fluorescent,incandescent,flash,horizon

Image Effect mode options :
none,negative,solarise,sketch,denoise,emboss,oilpaint,hatch,gpen,pastel,watercolour,film,blur,saturation,colourswap,washedout,posterise,colourpoint,colourbalance,cartoon

Metering Mode options :
average,spot,backlit,matrix

Dynamic Range Compression (DRC) options :
off,low,med,high

Preview parameter commands

-gs, --glscene  : GL scene square,teapot,mirror,yuv,sobel,vcsm_square
-gw, --glwin    : GL window settings <'x,y,w,h'>
enter code here