uwp之拍照(使用後置攝像頭)

2021-09-22 21:50:03 字數 2212 閱讀 8306

參考:wp8.1之拍照(獲取焦點,使用後置攝像頭)

首先 xaml**:

<

grid

background=""

>

<

grid

>

<

captureelement

x:name

="capturepreview"

stretch

="uniformtofill"

/>

<

image

name

="profilepic"

/>

grid

>

<

stackpanel

verticalalignment

="bottom"

>

<

slider

x:name

="focusvalueslider"

margin

="12,0,15,0"

header

="焦點調節:"

largechange

="25"

maximum

="1000"

minimum

="0"

smallchange

="1"

valuechanged

="focusvalueslider_valuechanged"

value

="500"

/>

<

stackpanel

orientation

="horizontal"

>

<

button

click

="photographbutton_click"

content

="啟動攝像頭"

/>

<

button

margin

="50,0,0,0"

click

="capturephoto_click"

content

="拍照"

/>

stackpanel

>

stackpanel

>

grid

>

//

啟動攝像頭

async

private

void photographbutton_click(object

sender, routedeventargs e)

var settings = new

mediacaptureinitializationsettings

;await

capturemanager.initializeasync(settings);

//攝像頭旋轉90度

capturepreview.source =capturemanager;

await

capturemanager.startpreviewasync();}}

private

static

async taskfindcameradevicebypanelasync(windows.devices.enumeration.panel desired)

//拍照

async

private

void capturephoto_click(object

sender, routedeventargs e)

}private

void focusvalueslider_valuechanged(object

sender, rangebasevaluechangedeventargs e)

catch

}//設定攝像頭焦點方法

private

async

void setfocus(uint? focusvalue = null

)

if(capturemanager.videodevicecontroller.focuscontrol.supported)

);await

capturemanager.videodevicecontroller.focuscontrol.focusasync();}}

catch

}

uwp之拍照(使用後置攝像頭)

參考 wp8.1之拍照 獲取焦點,使用後置攝像頭 首先 xaml grid background grid captureelement x name capturepreview stretch uniformtofill image name profilepic grid stackpanel...

攝像頭拍照

在windows下進行攝像頭拍照功能開發,可以借助開源的攝像頭專案或者一系列的demo。本程式實現乙個簡單的拍照功能,需要使用cximage庫,ccameraapi庫,這些都是開源的,我們可以直接使用它提供出來的介面就可以了。一 初始化攝像頭過程 之前得再ctakephotodlg類中建立乙個私有的...

使用USB攝像頭 Webcam 拍照

int cwebcamcamera startwebcam hwnd hparent,int nwidth,int nheight tchar szver max path bool bret capgetdriverdescription 0,szname,max path,szver,max p...