萬聖夜

今宵有糖吃。

800px-jack-o-lantern_2003-10-31
傑克南瓜燈

萬聖夜(英語:Halloween,為「All Hallows’ Eve」的縮寫,意為「萬聖節(諸聖節)的前夜」),意為萬聖節前夕,中文常訛稱為萬聖節,在每年的10月31日,是西方世界的傳統節日,主要流行於撒克遜人後裔雲集的美國、不列顛群島、澳大利亞、加拿大和紐西蘭等西方國家。當晚小孩會穿上化妝服,戴上面具,挨家挨戶收集糖果。

萬聖夜是諸聖節(All Hallows’ Day)的前夜。其英語名稱中的「Hallow」源於中古英語的「halwen」,與「holy」詞源很接近,在蘇格蘭和加拿大的某些區域,諸聖節仍然稱為「Allhallowmas」,意思是在紀念所有聖人(All Hallows)的那一天要舉行的彌撒(Mass)。

萬聖節通常與靈異的事物聯繫起來。歐洲傳統上認為萬聖夜是鬼怪世界最接近人間的時間,這傳說與東亞的中元節與盂蘭節以及日本的百鬼夜行類似。美國明尼蘇達州的阿諾卡(Anoka)號稱是「世界萬聖夜之都」,每年都舉行大型的巡遊慶祝。
 

 

 

 

 

 

 

樹莓派聲音︰ PWM

人們追求『原音重現』,

高傳真

高傳真英語:High fidelity,簡稱hi-fi)是家庭音響愛好者使用的術語,總體上要求音響系統在額定輸出功率下具有足夠高的信噪比 ,波形與輸入信號相比失真足夠低,並具有範圍足夠寬且在範圍內沒有明顯起伏的頻率響應。這一概念大約誕生於50年代,最初是完全主觀而無定量標準,1966年西德DIN(德國標準化學會)制定DIN 45500標準為高傳真的定量化和產品使用此稱謂的技術指標最低限提供了指導。[1] 到21世紀之後,隨著電子器件性能的提高,集成電路和數位技術的普及,市售的絕大多數廉價設備都能輕易達到60年代DIN所規定的最低標準,於是音響愛好 者對「高傳真」概念賦予了更主觀,更嚴苛的要求。為了追求聽感上的些微優越性,一些「發燒友」不惜在器材上投入巨資,比如更換貴金屬導線,而帶來的提高如 用常用的技術指標來形容,有時微不足道,其提高的原理有時也不易用普及性的電物理知識解釋,比如發燒友提出金質導線能帶來更純粹的音質,而從物理上說,金 材料的電阻率甚至大於銅 。於是,對高檔「高傳真」音響設備音質優越性的論斷,一直存在爭議,一些人試圖證明心理作用的影響,而發明了「AB盲聽」等一系列 有趣的實驗,不過迄今也沒有得出確切的結論,一般認為,理解的偏差可能和生理聽覺和大腦處理聲音的敏感度有關,也未必盡然是玄學

系統長久矣。時至今日,戴著耳機聽 mp3 彷彿才是時尚。這或許與高級音響依舊昂貴,若是不 知缺乏好的 Hi-Fi

High fidelity

High fidelity—or hi-fi or hifi—reproduction is a term used by home stereo listeners, audiophiles and home audio enthusiasts to refer to high-quality reproduction of sound[1] to distinguish it from the lower quality sound produced by inexpensive audio equipment, or the inferior quality of sound reproduction that can be heard in recordings made until the late 1940s.

Ideally, high-fidelity equipment has inaudible noise and distortion, and a flat (neutral, uncolored) frequency response within the intended frequency range.[2]

220px-audiovisual

Hi-fi speakers are a key component of quality audio reproduction.

 

揚聲器 Speakers 仍然無法欣賞音樂美聲,宛如在現場聽演唱會一般 。還請善待自己的耳朵,選個好點的喇叭,就可以輕鬆舒適地享受影音的樂趣也。

Adafruit 網頁上有一篇很好的文章

To keep the Raspberry Pi Zero as low cost and small as possible, the Pi foundation didn’t include a 3.5mm audio jack. There’s also no breakout pads for the audio output. This made us a little 🙁 at first but then we thought “hey you know, we can probably figure out how to get audio out with a little hacking!

How Audio Works on Other Pi Computers

The Broadcom chipset used for the Pi does not have a true analog output. Instead, two pins are PWM (pulse-width-modulated) at very high speeds, and filtered. The PWM frequency has to be at least 10x as high as the highest frequency we want to replicate in audio. Then, by adjusting the duty cycle of the PWM, we can ‘fake’ an audio signal.

Audio is 20Hz to 20KHz, and the PWM output from the Pi is 50MHz so we can easily filter the high 50MHz out (and anyways it cant be heard).

Looking at the Pi B schematic, we can see PWM0_OUT and PWM1_OUT are the left and right channels. R21 and R20 are voltage dividers to get the 3.3V signal down to about 1.1V max (that’s the max peak-to-peak voltage you want for audio line level.

C20/C26 works with R21/R27 to create an “RC low-pass filter”. You can calculate the cut-off frequency with 1/(2*pi*RC) = 1/(2*pi*270*33*10-9) = 17865 Hz which is pretty close to 20KHz!

C48/C34 acts as a DC-filter capacitor, it only allows AC through – speakers and headphones don’t like DC voltage!

Finally 8AV99 are ESD protection diodes. That’s to protect the Pi from static coming in and zapping the PWM pins..

Pi Zero PWM Audio

On the Pi Zero, we dont have pins PWM0 (pin #40) and PWM1 (pin #45)- those are not available on the PCB. That would normally be super 🙁 🙁 but it turns out that while those pads are not exposed, we can re-route those signals to other pins that we can get to!

You can get to PWM0 on GPIO #18 (ALT5) and PWM1 on GPIO #13 (ALT0) or GPIO #19 (ALT5) – see the full list of pins and alternate functions here

講述了樹莓派類比聲音輸出之電路和原理。不過 PWM

生 ︰何謂『脈衝寬度調變』 PWM Pulse-width modulation  ?《 網 》網說︰

500px-Duty_cycle_general.svg

Fig. 1: a pulse wave, showing the definitions of y_{min}, y_{max} and D.

350px-Pwm.svg

Fig. 2: A simple method to generate the PWM pulse train corresponding to a given signal is the intersective PWM: the signal (here the red sinewave) is compared with a sawtooth waveform (blue). When the latter is less than the former, the PWM signal (magenta) is in high state (1). Otherwise it is in the low state (0).

Pulse-width modulation uses a rectangular pulse wave whose pulse width is modulated resulting in the variation of the average value of the waveform. If we consider a pulse waveform f(t), with period T, low value y_{min}, a high value y_{max} and a duty cycle D (see figure 1), the average value of the waveform is given by:

<br /> \bar y=\frac{1}{T}\int^T_0f(t)\,dt.<br />

As f(t) is a pulse wave, its value is y_{max} for 0<t<D\cdot T and y_{min} for D\cdot T <t<T. The above expression then becomes:

"<br

This latter expression can be fairly simplified in many cases where y_{min}=0 as \bar y=D\cdot y_{max}. From this, it is obvious that the average value of the signal (\bar y) is directly dependent on the duty cycle D.

The simplest way to generate a PWM signal is the intersective method, which requires only a sawtooth or a triangle waveform (easily generated using a simple oscillator) and a comparator. When the value of the reference signal (the red sine wave in figure 2) is more than the modulation waveform (blue), the PWM signal (magenta) is in the high state, otherwise it is in the low state.

───《M♪o 之學習筆記本《丑》控制︰【紅火南】東籬南山

 

之解析度低、雜訊準位高、以及難以避免的抖動

Jitter

In electronics and telecommunications, jitter is the deviation from true periodicity of a presumably periodic signal, often in relation to a reference clock signal. In clock recovery applications it is called timing jitter.[1] Jitter is a significant, and usually undesired, factor in the design of almost all communications links.

Jitter can be quantified in the same terms as all time-varying signals, e.g., root mean square (RMS), or peak-to-peak displacement. Also like other time-varying signals, jitter can be expressed in terms of spectral density.

Jitter period is the interval between two times of maximum effect (or minimum effect) of a signal characteristic that varies regularly with time. Jitter frequency, the more commonly quoted figure, is its inverse. ITU-T G.810 classifies jitter frequencies below 10 Hz as wander and frequencies at or above 10 Hz as jitter.[2]

Jitter may be caused by electromagnetic interference and crosstalk with carriers of other signals. Jitter can cause a display monitor to flicker, affect the performance of processors in personal computers, introduce clicks or other undesired effects in audio signals, and cause loss of transmitted data between network devices. The amount of tolerable jitter depends on the affected application.

……

Sampling jitter

In analog to digital and digital to analog conversion of signals, the sampling is normally assumed to be periodic with a fixed period—the time between every two samples is the same. If there is jitter present on the clock signal to the analog-to-digital converter or a digital-to-analog converter, the time between samples varies and instantaneous signal error arises. The error is proportional to the slew rate of the desired signal and the absolute value of the clock error. Various effects such as noise (random jitter), or spectral components (periodic jitter)[specify] can come about depending on the pattern of the jitter in relation to the signal. In some conditions, less than a nanosecond of jitter can reduce the effective bit resolution of a converter with a Nyquist frequency of 22 kHz to 14 bits.[4]

This is a consideration in high-frequency signal conversion, or where the clock signal is especially prone to interference.

 

在 Hi-Fi 的召喚下,催促人們踏上 I2S Quest 之旅!!

 

 

 

 

 

 

 

 

 

樹莓派聲音︰頃聽者

登廬山望石門‧宋鮑照

訪世失隱淪,從山異靈士。
明發振雲冠,升嶠遠棲趾。
高岑隔半天,長崖斷千里。
氛霧承星辰,潭壑洞江汜。
嶄絕類虎牙,巑岏象熊耳。
埋冰或百年,韜樹必千祀。
雞鳴清澗中,猿嘯白雲裏。
瑤波逐穴開,霞石觸峰起。
迴互非一形,參差悉相似。
傾聽鳳管賓,緬望釣龍子。
松桂盈膝前,如何穢城市。

 

振羽 %e7%be%bd 騰空之時,音聲分明。發芽 %e8%8a%bd 伏藏之際,難得頃聽。

一則樹莓派探索者追尋更好聲音的故事,早已悄悄展開︰

by dariush » Fri Jun 15, 2012 7:52 pm

Hi,

I’m currently experimenting with the I2S/PCM interface.

(I know, PCM_FS isn’t accessible as a GPIO on the RasberryPi, but PCM_CLK and PCM_DOUT are, which might be useful enough for certain use cases).

However I’m having trouble getting the I2S system to work. Maybe I misread the datasheet.
For starters I’ve configured the registers to 2x16bit Channels, enabled I2S and filled the FIFO with 64 words (see code below).

Unfortunately I don’t see any output on either GPIO18 or 21.

Furthermore a couple of status bits aren’t updated as I would expect after reading the datasheet.
Most troubling is that the SYNC register (p.126) is always reading 0, no matter what I’m writing into it.

Attached is a simple userspace program (based on the GPIO demo from the elinux wiki).
It configures and enables I2S and fills the FIFO in a loop.

I’m totally clueless at the moment. Either I made a mistake or the datasheet is missing some vital information. Did anyone else have a look into the I2S system and has some idea what I might have missed?

cheers
Dariush

(compile with “gcc -o i2s i2s.c”)

    //
    //  How to access GPIO registers from C-code on the Raspberry-Pi
    //  Example program
    //  15-January-2012
    //  Dom and Gert
    //  source: http://elinux.org/RPi_Low-level_peripherals

    #define BCM2708_PERI_BASE        0x20000000
    #define GPIO_BASE                (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */
    #define I2S_BASE                (BCM2708_PERI_BASE + 0x203000) /* GPIO controller */


    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <dirent.h>
    #include <fcntl.h>
    #include <assert.h>
    #include <sys/mman.h>
    #include <sys/types.h>
    #include <sys/stat.h>

    #include <unistd.h>

    #define PAGE_SIZE (4*1024)
    #define BLOCK_SIZE (4*1024)

    int  mem_fd;
    char *gpio_mem, *gpio_map;
    char *i2s_mem, *i2s_map;


    // I/O access
    volatile unsigned *gpio;
    volatile unsigned *i2s;


    // GPIO setup macros. Always use INP_GPIO(x) before using OUT_GPIO(x) or SET_GPIO_ALT(x,y)
    #define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
    #define OUT_GPIO(g) *(gpio+((g)/10)) |=  (1<<(((g)%10)*3))
    #define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))

    #define GPIO_SET *(gpio+7)  // sets   bits which are 1 ignores bits which are 0
    #define GPIO_CLR *(gpio+10) // clears bits which are 1 ignores bits which are 0

    void setup_io();

    int main(int argc, char **argv)
    { int g,rep;

      setup_io();

      printf("Setting GPIO regs to alt0\n");
      for (g=18; g<=21; g++)
      {
        INP_GPIO(g);
        SET_GPIO_ALT(g,0);
      }

     int i;
     printf("Memory dump\n");
     for(i=0; i<10;i++) {
        printf("GPIO memory address=0x%08x: 0x%08x\n", gpio+i, *(gpio+i));
     }

      // disable I2S so we can modify the regs
      printf("Disable I2S\n");
      *(i2s+0) = 0;
      usleep(10);
     
      // XXX: seems not to be working. FIFO still full, after this.
      printf("Clearing FIFOs\n");
      *(i2s+0) |= 1<<3 | 1<<4 | 11<5; // clear TX FIFO
      usleep(10);
     
      // set register settings
      // --> enable Channel1 and channel2
      // --> set channel both width to 16 bit
      printf("Setting TX channel settings\n");
      *(i2s+4) = 1<<30 | 8<<16 | 1<<14 | 16<<4 | 8<<0;
      // --> frame width 31+1 bit
      *(i2s+2) = 31<<10;

      // --> disable STBY
      printf("disabling standby\n");
      *(i2s+0) |= 1<<25;
      usleep(50);

      // --> ENABLE SYNC bit
      printf("setting sync bit high\n");
      *(i2s+0) |= 1<<24;
      usleep(50);
     
      if (*(i2s+0) & 1<<24) {
        printf("SYNC bit high, as expected.\n");
      } else {
        printf("SYNC bit low, strange.\n");
      }

      // enable I2S
      *(i2s+0) |= 0x01;

      usleep(10);

      // enable transmission
      *(i2s+0) |= 0x04;

      // fill FIFO in while loop
      int count=0;
      printf("going into loop\n");
      while (1) {
     
        while ((*i2s) & (1<<19)) {
          // FIFO accepts data
          *(i2s+1) = 0xAAAAAAAA;
         
          printf("Filling FIFO, count=%i\n", ++count);
        }
       
        // Toogle SYNC Bit
        //( XXX: do I have to deactivate I2S to do that? datasheet is unclear)
        *(i2s+0) &= ~(0x01);
        *(i2s+0) ^= 1<<24;
        *(i2s+0) |= 0x01;

        sleep(1);
       
        printf("Memory dump\n");
        for(i=0; i<9;i++) {
           printf("I2S memory address=0x%08x: 0x%08x\n", i2s+i, *(i2s+i));
        }

      }

      return 0;

    } // main


    //
    // Set up a memory regions to access GPIO
    //
    void setup_io()
    {
      printf("setup io\n");

       /* open /dev/mem */
       if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
          printf("can't open /dev/mem \n");
          exit (-1);
       }

       /* mmap GPIO */

       // Allocate MAP block
       if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) {
          printf("allocation error \n");
          exit (-1);
       }

       // Allocate MAP block
       if ((i2s_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) {
          printf("allocation error \n");
          exit (-1);
       }

       // Make sure pointer is on 4K boundary
       if ((unsigned long)gpio_mem % PAGE_SIZE)
         gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE);
       // Make sure pointer is on 4K boundary
       if ((unsigned long)i2s_mem % PAGE_SIZE)
         i2s_mem += PAGE_SIZE - ((unsigned long)i2s_mem % PAGE_SIZE);

       // Now map it
       gpio_map = (unsigned char *)mmap(
          (caddr_t)gpio_mem,
          BLOCK_SIZE,
          PROT_READ|PROT_WRITE,
          MAP_SHARED|MAP_FIXED,
          mem_fd,
          GPIO_BASE
       );

       // Now map it
       i2s_map = (unsigned char *)mmap(
          (caddr_t)i2s_mem,
          BLOCK_SIZE,
          PROT_READ|PROT_WRITE,
          MAP_SHARED|MAP_FIXED,
          mem_fd,
          I2S_BASE
       );

       if ((long)gpio_map < 0) {
          printf("mmap error %d\n", (int)gpio_map);
          exit (-1);
       }
       if ((long)i2s_map < 0) {
          printf("mmap error %d\n", (int)i2s_map);
          exit (-1);
       }

       // Always use volatile pointer!
       gpio = (volatile unsigned *)gpio_map;
       i2s = (volatile unsigned *)i2s_map;


    } // setup_io

 

 

 

 

 

 

 

 

 

 

樹莓派相機︰ PiCamera 《三》

『問題』有時比『答案』有趣乎?祇因『懸疑』未決耶!

所謂『玩科技』自得其樂者也☆

pi@raspberrypi:~/test ipython3  Python 3.4.2 (default, Oct 19 2014, 13:31:11)  Type "copyright", "credits" or "license" for more information.  IPython 2.3.0 -- An enhanced Interactive Python. ?         -> Introduction and overview of IPython's features. %quickref -> Quick reference. help      -> Python's own help system. object?   -> Details about 'object', use 'object??' for extra details.  In [1]: from io import BytesIO  In [2]: from picamera import PiCamera  In [3]: from PIL import Image  In [4]: 串流 = BytesIO()  In [5]: 相機 = PiCamera()  In [6]: 相機.resolution = (1024, 768)  In [7]: 相機.capture(串流, format='jpeg')  In [8]: 串流.seek(0) Out[8]: 0  In [9]: 擷取影像 = Image.open(串流)  In [10]: 擷取影像.show()  In [11]:  </pre> <img class="alignnone size-full wp-image-62130" src="http://www.freesandal.org/wp-content/uploads/PIL1024x768.png" alt="pil1024x768" width="1026" height="797" />    <pre class="lang:python decode:true">pi@raspberrypi:~/test ipython3 
Python 3.4.2 (default, Oct 19 2014, 13:31:11) 
Type "copyright", "credits" or "license" for more information.

IPython 2.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import picamera

In [2]: import numpy as np

In [3]: import matplotlib.pyplot as plt

In [4]: 相機 = picamera.PiCamera()

In [5]: 相機.resolution = (320, 240)

In [6]: RGB空矩陣 = np.empty((240, 320, 3), dtype=np.uint8)

In [7]: 相機.capture(RGB空矩陣, 'rgb')

In [8]: type(RGB空矩陣)
Out[8]: numpy.ndarray

In [9]: RGB空矩陣.shape
Out[9]: (240, 320, 3)

In [10]: plt.imshow(RGB空矩陣)
Out[10]: <matplotlib.image.AxesImage at 0x6e023a50>

In [11]: plt.show()

In [12]: 

plt320x240

 

 

 

 

 

 

 

 

 

 

樹莓派相機︰ PiCamera 《二》

然而程式整合常常卻沒那麼簡單︰

scikit-video

Installing scikit-video is easy!

$ sudo pip install sk-video

If you have any installation issues, consult the FAQ. If you still have trouble, please report the issue on github.

Scikit-video is designed for easy video processing using Python. It is modeled in the spirit of other successful scikits such as scikit-learn and scikit-image. The developers of scikit-video know libraries exist for manipulating videos, such as PyFFmpeg, MoviePy, PyAV, imageIO, and opencv. However, no libraries have been found to provide an all-in-one solution for research-level video processing tools.

This project aims to make video algorithms easy to access for students, engineers, instructors, and researchers. Choose a category below to start learning how to use scikit-video!

………

比方說添加

【派生科學程式庫安裝】

sudo apt-get install python-numpy
sudo apt-get install python-numpy
sudo apt-get install python-scipy
sudo apt-get install python3-scipy
sudo apt-get install python-skimage 
sudo apt-get install python3-skimage

【派生總變差程式庫安裝】

sudo apt-get install python-cffi python3-cffi
sudo apt-get install liblapacke-dev
sudo apt-get install libblas-dev
sudo apt-get install liblapack-dev
sudo pip install prox-tv
sudo pip3 install prox-tv

借著

proxTV

Matlab and Python toolbox for fast Total Variation proximity operators.

For an up-to-date version, check https://github.com/albarji/proxTV .

Introduction

proxTV is a toolbox implementing blazing fast implementations of Total Variation proximity operators. While the core algorithms are implemented in C to achieve high efficiency, Matlab and Python interfaces are provided for ease of use.

The library provides efficient solvers for the following Total Variation proximity problems:

Problem Formulation
Standard (l1) Total Variation on a 1-dimensional signal alt tag
Quadratic (l2) Total Variation on a 1-dimensional signal alt tag
lp-norm Total Variation on a 1-dimensional signal alt tag
Weighted Total Variation on a 1-dimensional signal alt tag
Anisotropic Total Variation on a 2-dimensional signal alt tag
lp-norm Anisotropic Total Variation on a 2-dimensional signal alt tag
Weighted Anisotropic Total Variation on a 2-dimensional signal alt tag
Anisotropic Total Variation on a 3-dimensional signal alt tag
Generalized N-dimensional Anisotropic Total Variation alt tag, with X(di) every possible 1-dimensional slice of X following dimension di.

───

可以探索

Total variation

In mathematics, the total variation identifies several slightly different concepts, related to the (local or global) structure of the codomain of a function or a measure. For a real-valued continuous function f, defined on an interval [a, b] ⊂ ℝ, its total variation on the interval of definition is a measure of the one-dimensional arclength of the curve with parametric equation xf(x), for x ∈ [a, b].

Total_variation

As the green ball travels on the graph of the given function, the length of the path travelled by that ball’s projection on the y-axis, shown as a red ball, is the total variation of the function.

───

之旨趣。甚或能得『雜訊處理』之門徑耶!!

───《W!o+ 的《小伶鼬工坊演義》︰神經網絡【轉折點】六

 

利用

4. Advanced Recipes

The following recipes involve advanced techniques and may not be “beginner friendly”. Please feel free to suggest enhancements or additional recipes.

4.1. Capturing to a numpy array

Since 1.11, picamera can capture directly to any object which supports Python’s buffer protocol (including numpy’s ndarray). Simply pass the object as the destination of the capture and the image data will be written directly to the object. The target object must fulfil various requirements (some of which are dependent on the version of Python you are using):

  1. The buffer object must be writeable (e.g. you cannot capture to a bytes object as it is immutable).
  2. The buffer object must be large enough to receive all the image data.
  3. (Python 2.x only) The buffer object must be 1-dimensional.
  4. (Python 2.x only) The buffer object must have byte-sized items.

For example, to capture directly to a three-dimensional numpy ndarray (Python 3.x only):

import time
import picamera
import numpy as np

with picamera.PiCamera() as camera:
    camera.resolution = (320, 240)
    camera.framerate = 24
    time.sleep(2)
    output = np.empty((240, 320, 3), dtype=np.uint8)
    camera.capture(output, 'rgb')

It is also important to note that when outputting to unencoded formats, the camera rounds the requested resolution. The horizontal resolution is rounded up to the nearest multiple of 32 pixels, while the vertical resolution is rounded up to the nearest multiple of 16 pixels. For example, if the requested resolution is 100×100, the capture will actually contain 128×112 pixels worth of data, but pixels beyond 100×100 will be uninitialized.

So, to capture a 100×100 image we first need to provide a 128×112 array, then strip off the uninitialized pixels afterward. The following example demonstrates this along with the re-shaping necessary under Python 2.x:

import time
import picamera
import numpy as np

with picamera.PiCamera() as camera:
    camera.resolution = (100, 100)
    camera.framerate = 24
    time.sleep(2)
    output = np.empty((112 * 128 * 3,), dtype=np.uint8)
    camera.capture(output, 'rgb')
    output = output.reshape((112, 128, 3))
    output = output[:100, :100, :]
 Warning

Under certain circumstances (non-resized, non-YUV, video-port captures), the resolution is rounded to 16×16 blocks instead of 32×16. Adjust your resolution rounding accordingly.

New in version 1.11.

numpy array 溝通不同程式庫之間的資料轉換。

此事想必廚師早知道的吧☆