廢話不多說,直接上原始碼
public
class
mainactivity
extends
activity
private string filename;
private uri imguri;
private file img;
public
void
go(view view)
//3)每一張新的名字要具體唯一性 yyyy-mm-dd-hh-mm-ss.jpg
//4) 呼叫攝像頭
intent i = new intent(android.provider.mediastore.
action_image_capture); // 攝像頭對應的action就是這個
img = new file(tocean,filename); // 建立儲存路徑的file物件
imguri = uri.fromfile(img); // 把儲存影象轉為uri形式
i.putextra(android.provider.mediastore.extra_output, imguri);
startactivityforresult(i, 1);
}}
@override
protected
void
onactivityresult(int requestcode, int resultcode, intent data)
}if(requestcode == 2)
}super.onactivityresult(requestcode, resultcode, data);
}}
希望對安卓初學者有所幫助 Android 呼叫攝像頭
androidmanifest新增許可權 intent呼叫開啟照相機 intent intent new intent mediastore.action image capture file file new file environment.getexternalstoragedirectory...
Python呼叫攝像頭
如下 import cv2 import numpy 建立攝像頭物件 cap cv2.videocapture videotest test1.mp4 cap cv2.videocapture 0 引數為本地攝像頭 cap cv2.videocapture 1 引數為usb攝像頭 while 1 r...
ffmpeg nginx dash呼叫攝像頭直播
參考 nginx安裝,需原始碼編譯,因為需要新增nginx rtmp module 模組 其次nginx的版本不要太低,以免make的時候出錯。安裝依賴 sudo apt get update sudo apt get install libpcre3 libpcre3 dev sudo apt g...