Merge pull request #2443 from coloka/master

【翻译完成】20150121 How to apply image effects to pictures on Raspberry Pi
This commit is contained in:
geekpi 2015-02-24 10:54:41 +08:00
commit bdb74aa67d
3 changed files with 72 additions and 70 deletions

View File

@ -1,3 +1,4 @@
translating by coloka
What are useful command-line network monitors on Linux
================================================================================
Network monitoring is a critical IT function for businesses of all sizes. The goal of network monitoring can vary. For example, the monitoring activity can be part of long-term network provisioning, security protection, performance troubleshooting, network usage accounting, and so on. Depending on its goal, network monitoring is done in many different ways, such as performing packet-level sniffing, collecting flow-level statistics, actively injecting probes into the network, parsing server logs, etc.

View File

@ -1,70 +0,0 @@
Translating by coloka
How to apply image effects to pictures on Raspberry Pi
================================================================================
Like a common pocket camera which has a built-in function to add various effects on captured photos, [Raspberry Pi camera board][1] ("raspi cam") can actually do the same. With the help of raspistill camera control options, we can add the image effects function like we have in a pocket camera.
There are [three comman-line applications][2] which can be utilized for [taking videos or pictures][3] with raspi cam, and one of them is the raspistill application. The raspistill tool offers various camera control options such as sharpness, contrast, brightness, saturation, ISO, exposure, automatic white balance (AWB), image effects.
In this article I will show how to apply exposure, AWB, and other image effects with raspistill while capturing pictures using raspi cam. To automate the process, I wrote a simple Python script which takes pictures and automatically applies a series of image effects to the pictures. The raspi cam documentation describes available types of the exposure, AWB, and image effects. In total, the raspi cam offers 16 types of image effects, 12 types of exposure, and 10 types of AWB values.
The simple Python script looks like the following.
#!/usb/bin/python
import os
import time
import subprocess
list_ex=['auto','night']
list_awb=['auto','cloud',flash']
list_ifx=['blur','cartoon','colourswap','emboss','film','gpen','hatch','negative','oilpaint','posterise','sketch','solarise','watercolour']
x=0
for ex in list_ex:
for awb in list_awb:
for ifx in list_ifx:
x=x+1
filename='img_'+ex+'_'+awb+'_'+ifx+'.jpg'
cmd='raspistill -o '+filename+' -n -t 1000 -ex '+ex+' -awb '+awb+' -ifx '+ifx+' -w 640 -h 480'
pid=subprocess.call(cmd,shell=True)
print "["+str(x)+"]-"+ex+"_"+awb+"_"+ifx+".jpg"
time.sleep(0.25)
print "End of image capture"
The Python script operates as follows. First, create three array/list variable for the exposure, AWB and image effects. In the example, we use 2 types of exposure, 3 types of AWB, and 13 types of image effects values. Then make nested loops for applying the value of the three variables that we have. Inside the nested loop, execute the raspistill application. We specify (1) the output filename; (2) exposure value; (3) AWB value; (4) image effect value; (5) the time to take a photo, which is set to 1 second; and (6) the size of the photo, which is set to 640x480px. This Python script will create 78 different versions of a captured photo with a combination of 2 types of exposure, 3 types of AWB, and 13 types of image effects.
To execute the Python script, simply type:
$ python name_of_this_script.py
Here is the first round of the sample result.
![](https://farm8.staticflickr.com/7483/16134215939_c93291158a_c.jpg)
### Bonus ###
For those who are more interested, there is another way to access and control the raspi cam besides raspistill. [Picamera][4] a pure Python interface which provides APIs for accessing and controlling raspi cam, so that one can build a complex program for utilizing raspi cam according to their needs. If you are skilled at Python, picamera is a good feature-complete interface for implementing your raspi cam project. The picamera interface is included by default in the recent image of Raspbian. If your [Raspberry Pi][5] operating system is not new or not Raspbian, you can install it on your system as follows.
First, install pip on your system by following [this guideline][6].
Then, install picamera as follows.
$ sudo pip install picamera
Refer to the [official documentation][7] on how to use picamera.
--------------------------------------------------------------------------------
via: http://xmodulo.com/apply-image-effects-pictures-raspberrypi.html
作者:[Kristophorus Hadiono][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/kristophorus
[1]:http://xmodulo.com/go/picam
[2]:http://www.raspberrypi.org/documentation/usage/camera/raspicam/
[3]:http://xmodulo.com/install-raspberry-pi-camera-board.html
[4]:https://pypi.python.org/pypi/picamera
[5]:http://xmodulo.com/go/raspberrypi
[6]:http://ask.xmodulo.com/install-pip-linux.html
[7]:http://picamera.readthedocs.org/

View File

@ -0,0 +1,71 @@
如何在树莓派上使用图片特效
================================================================================
现在使用[树莓派摄像头模组][1]("raspi cam"),也可以像使用卡片相机那样,给拍摄的照片增加各种各样的图片特效。 raspistill命令行工具为您的树莓派提供了丰富的图片特效选项来美化处理你的图片。
你可以用[这3个命令行工具][2]来[抓取raspicam拍摄的照片或者视频][3]在这文章中将重点介绍其中的raspstill工具。raspstill工具提供了丰富的控制选项来处理图片比如说锐度sharpness、对比度contrast、亮度brightness、饱和度saturation、ISO、自动白平衡AWB、以及图片特效image effect等。
在这篇文章中将介绍如何使用raspstill工具以及raspicam摄像头模组来控制照片的曝光、AWB以及其他的图片效果。我写了一个简单的python脚本来自动拍摄照片并在这些照片上自动应用各种图片特效。raspicam的帮助文档中介绍了该摄像头模组所支持的曝光模式、AWB和图片特效。总的来说raspicam一共支持16种图片特效、12种曝光模式以及10种AWB选项。
Python脚本很简单如下所示 。
#!/usb/bin/python
import os
import time
import subprocess
list_ex=['auto','night']
list_awb=['auto','cloud',flash']
list_ifx=['blur','cartoon','colourswap','emboss','film','gpen','hatch','negative','oilpaint','posterise','sketch','solarise','watercolour']
x=0
for ex in list_ex:
for awb in list_awb:
for ifx in list_ifx:
x=x+1
filename='img_'+ex+'_'+awb+'_'+ifx+'.jpg'
cmd='raspistill -o '+filename+' -n -t 1000 -ex '+ex+' -awb '+awb+' -ifx '+ifx+' -w 640 -h 480'
pid=subprocess.call(cmd,shell=True)
print "["+str(x)+"]-"+ex+"_"+awb+"_"+ifx+".jpg"
time.sleep(0.25)
print "End of image capture"
The Python script operates as follows. First, create three array/list variable for the exposure, AWB and image effects. In the example, we use 2 types of exposure, 3 types of AWB, and 13 types of image effects values. Then make nested loops for applying the value of the three variables that we have. Inside the nested loop, execute the raspistill application. We specify (1) the output filename; (2) exposure value; (3) AWB value; (4) image effect value; (5) the time to take a photo, which is set to 1 second; and (6) the size of the photo, which is set to 640x480px. This Python script will create 78 different versions of a captured photo with a combination of 2 types of exposure, 3 types of AWB, and 13 types of image effects.
这个脚本完成了以下几个工作。首先脚本中定义了3个列表分别用于枚举曝光模式、AWB模式以及图片特效。在这个实例中我们将使用到2种曝光模式、3种AWB模式以及13种图片特效。脚本会遍历上述3种选项的各种组合并使用这些参数组合来运行raspistill工具。传入的参数共6个分别为1输出文件名2曝光模式3AWB模式4图片特效模式5拍照时间设为1秒6图片尺寸设为640x480。脚本会自动拍摄78张照片每张照片会应用不同的特效参数。
执行这个脚本也很简单,只需键入下面的命令行:
$ python name_of_this_script.py
下面是抓取到一些样张。
![](https://farm8.staticflickr.com/7483/16134215939_c93291158a_c.jpg)
### 小福利 ###
除了使用raspistill命令行工具来操控raspicam摄像模组以外还有其他的方法可以用哦。[Picamera][4]是一个python库它提供了操控raspicam摄像模组的的API接口这样就可以便捷地构建更加复杂的应用程序。如果你精通python那么picamera一定是你项目的好伙伴。picamera已经被默认集成到Raspbian最新版本的的镜像中。当然如果你用的不是最新的Raspbian或者是使用其他的操作系统版本你可以通过下面的方法来进行手动安装。
首先先在你的系统上安装pip详见[指导][6]。
然后就可以按下面的方法安装picamera。
$ sudo pip install picamera
picamera的使用说明可以查阅[官方文档][7]。
--------------------------------------------------------------------------------
via: http://xmodulo.com/apply-image-effects-pictures-raspberrypi.html
作者:[Kristophorus Hadiono][a]
译者:[coloka](https://github.com/coloka)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/kristophorus
[1]:http://xmodulo.com/go/picam
[2]:http://www.raspberrypi.org/documentation/usage/camera/raspicam/
[3]:http://xmodulo.com/install-raspberry-pi-camera-board.html
[4]:https://pypi.python.org/pypi/picamera
[5]:http://xmodulo.com/go/raspberrypi
[6]:http://ask.xmodulo.com/install-pip-linux.html
[7]:http://picamera.readthedocs.org/