分类 硬件/开发板 下的文章

使用Armbian系统可以很方便的使用h3disp来设置。

root@orangepione:~# h3disp -m
    480i        use "-m 480i" or "-m 0"
    576i        use "-m 576i" or "-m 1"
    480p        use "-m 480p" or "-m 2"
    576p        use "-m 576p" or "-m 3"
    720p50      use "-m 720p50" or "-m 4"
    720p60      use "-m 720p60" or "-m 5"
    1080i50     use "-m 1080i50" or "-m 6"
    1080i60     use "-m 1080i60" or "-m 7"
    1080p24     use "-m 1080p24" or "-m 8"
    1080p50     use "-m 1080p50" or "-m 9"
    1080p60     use "-m 1080p60" or "-m 10"
    1080p25     use "-m 1080p25" or "-m 11"
    1080p30     use "-m 1080p30" or "-m 12"
    1080p24_3d  use "-m 1080p24_3d" or "-m 13"
    720p50_3d   use "-m 720p50_3d" or "-m 14"
    720p60_3d   use "-m 720p60_3d" or "-m 15"
    1080p24_3d  use "-m 1080p24_3d" or "-m 23"
    720p50_3d   use "-m 720p50_3d" or "-m 24"
    720p60_3d   use "-m 720p60_3d" or "-m 25"
    1080p25     use "-m 1080p25" or "-m 26"
    1080p30     use "-m 1080p30" or "-m 27"
    4kp30       use "-m 4kp30" or "-m 28"
    4kp25       use "-m 4kp25" or "-m 29"
    800x480     use "-m 800x480" or "-m 31"
    1024x768    use "-m 1024x768" or "-m 32"
    1280x1024   use "-m 1280x1024" or "-m 33"
    1360x768    use "-m 1360x768" or "-m 34"
    1440x900    use "-m 1440x900" or "-m 35"
    1680x1050   use "-m 1680x1050" or "-m 36"
    2048x1536   use "-m 2048x1536" or "-m 37"

 Two examples:
    'h3disp -m 1080p60 -d' (1920x1080@60Hz DVI)
    'h3disp -m 720i' (1280x720@30Hz HDMI)

1.安装PyGame(Apt方式):

sudo apt-get install python-pygame

2.安装PyGame(Pip方式):

pip install pygame

3.代码

import pygame
import pygame.camera
from pygame.locals import *  #引用

pygame.init()
pygame.camera.init()  #初始化

camera = pygame.camera.Camera("/dev/video0", (1280, 720))  #指定设备,设置宽度高度
camera.start()
image = camera.get_image()  #Get
pygame.image.save(image, "image.jpg")  #保存
camera.stop() 

还是非常简单的,通过网页控制ESP8266,直接访问ESP8266的IP就行了。

代码:

//请先部署 ESP8266 for Arduino 环境
//随便注释了一下
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char* ssid = "WIFINAME";
const char* pass = "PASSWORD";
ESP8266WebServer server(80);//端口
int pin = 2;
String gethtml(){//Html
    String h; //= "HTTP/1.1 200 OK\r\n";
    h += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
    h += "<style type=\"text/css\"> body{text-align: center;} </style>";
    h += "<!DOCTYPE HTML>";
    h += "<html>";
    h += "<p>ESP8266</p>";
    h += "<p>当前状态:";
    if(digitalRead(pin) == 1){
        h += "关";
    }else{
        h += "开";
    }
    h += "</p>";
    h += "<a href=\"on\"><button>on</button></a>";
    h += "<p>&nbsp;</p>";
    h += "<a href=\"off\"><button>off</button></a>";
    h += "<p>Powered by chutian.bid  (低电平触发)</p>";
    h += "</html>";
    return h;
}
void onl(){
    digitalWrite(pin,LOW);
    Serial.println("on 0");
    server.send(200, "text/html",gethtml());
}
void offl(){
    digitalWrite(pin,HIGH);
    Serial.println("off 1");
    server.send(200, "text/html",gethtml());
}
void htmlout(){
    server.send(200, "text/html",gethtml());
}
void readl(){
    char* h;
    if(digitalRead(pin) == 1){
        h = "off";
    }else{
        h = "on";
    }
    server.send(200, "text/html",h);
}
void setup() {
    Serial.begin(9600);
    Serial.println();
    Serial.println("ESP8266");
    pinMode(pin,OUTPUT);
    digitalWrite(pin, 1);//低电触发
    WiFi.begin(ssid,pass);//连接WiFi
    while(WiFi.status() != WL_CONNECTED){//连接判断
        delay(300);
        Serial.print(".");
    }
    Serial.println();
    Serial.println(WiFi.localIP());//取IP
    server.on("/on",onl);
    server.on("/off",offl);
    server.on("/read",readl);
    server.onNotFound(htmlout);
    server.begin();//开始
}
void loop() {
    server.handleClient();//循环
}