|
本帖最后由 code-AR 于 2015-3-22 22:48 编辑
很长段时间没有混在论坛了,平时就是签个到。今天带了个新玩意吧,利用VC0706串口摄像头定时拍摄照片,以制作延时摄影
不知道什么是延时摄影的,自行度娘去。整个流程就是用arduino来控制摄像头拍摄照片,并存储到SD卡中,最后用SD卡中的照片来制作延时摄影的影片,利用了arduino UNO,外加SD卡模块,VC0706串口摄像头(可以在加个蓝牙模块,监控拍摄信息)。来个简陋的硬件图吧,
→_→
这些组合起来,再外加个5000mAH的移动电源。用个纸盒包装起来,即可成个延时摄影器材,电力可以支持十几个小时的拍摄工作。再来就是硬件的连接图(其中的蓝牙模块,可要,可不要。我主要是拿来检测拍摄信息的)
→_→
代码部分(基于vc0706的库文件的例程修改) - //自动延时摄影
- //MCU内部自走时,设定时间,驱动VC0706进行拍照
- //库文件定义声明
- #include <Adafruit_VC0706.h>
- #include <SPI.h>
- #include <SD.h>
- #include <SoftwareSerial.h>
- // sd卡CS/SS端接pin 10
- #define chipSelect 10
- #define DelayTime 30000//定义延时时间
- static long timer;
- // 对于 Uno: camera TX 接 pin 2, camera RX 接 pin 3:
- SoftwareSerial cameraconnection = SoftwareSerial(2, 3);
- Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);
- void setup() {
- pinMode(10, OUTPUT); // SS on Uno, etc.
- Serial.begin(9600);
- Serial.println("VC0706 Camera test");
-
- // see if the card is present and can be initialized:
- if (!SD.begin(chipSelect)) {
- Serial.println("Card failed, or not present");
- // don't do anything more:
- return;
- }
-
- // Try to locate the camera
- if (cam.begin()) {
- Serial.println("Camera Found:");
- } else {
- Serial.println("No camera found?");
- return;
- }
- // Print out the camera version information (optional)
- char *reply = cam.getVersion();
- if (reply == 0) {
- Serial.print("Failed to get version");
- } else {
- Serial.println("-----------------");
- Serial.print(reply);
- Serial.println("-----------------");
- }
- // 设置照片尺寸 - 640x480, 320x240 or 160x120
- //cam.setImageSize(VC0706_640x480); // biggest
- cam.setImageSize(VC0706_320x240); // medium
- //cam.setImageSize(VC0706_160x120); // small
- // You can read the size back from the camera (optional, but maybe useful?)
- uint8_t imgsize = cam.getImageSize();
- Serial.print("Image size: ");
- if (imgsize == VC0706_640x480) Serial.println("640x480");
- if (imgsize == VC0706_320x240) Serial.println("320x240");
- if (imgsize == VC0706_160x120) Serial.println("160x120");
-
- timer = 0;
- }
- void loop() {
- if (millis() > timer + DelayTime) {
- timer = millis();
- Serial.println("Delay Done!");
-
- if (! cam.takePicture())
- Serial.println("Failed to snap!");
- else
- Serial.println("Picture taken!");
-
- char filename[13];
- strcpy(filename, "IMAGE000.JPG");
- //设定是最大1000张,即IMAGE000至999
- for (int i = 0; i < 1000; i++) {
- filename[5] = '0' + i/100;
- filename[6] = '0' + (i%100)/10;
- filename[7] = '0' + (i%100)%10;
- // create if does not exist, do not open existing, write, sync after write
- if (! SD.exists(filename)) {
- break;
- }
- }
-
- File imgFile = SD.open(filename, FILE_WRITE);
-
- uint16_t jpglen = cam.frameLength();
- Serial.print(jpglen, DEC);
- Serial.println(" byte image");
-
- Serial.print("Writing image to "); Serial.print(filename);
-
- while (jpglen > 0) {
- // read 32 bytes at a time;
- uint8_t *buffer;
- uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
- buffer = cam.readPicture(bytesToRead);
- imgFile.write(buffer, bytesToRead);
- //Serial.print("Read "); Serial.print(bytesToRead, DEC); Serial.println(" bytes");
- jpglen -= bytesToRead;
- }
- imgFile.close();
- Serial.println("...Done!");
- cam.resumeVideo();
- }
- }
复制代码
自己制作的视频(渣画质,慎点),外加vc0706库文件。。。
希望有兴趣的朋友,可以分享自己拍摄的作品那,也可以在这个基础上完成其他好作品,谢谢!!!
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|