我的应用程序应保存相机中的图像.我写了下面的代码:
初始化相机的方法.
Windows.Media.Capture.MediaCapture takePhotoManager;
public async void InitializeCamera()
{
takePhotoManager = new Windows.Media.Capture.MediaCapture();
await takePhotoManager.InitializeAsync();
takePhotoManager.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
PhotoPreview.Source = takePhotoManager;
await takePhotoManager.StartPreviewAsync();
// to stop it
//await takePhotoManager.StopPreviewAsync();
}
Run Code Online (Sandbox Code Playgroud)保存照片的方法:
public async void SavePhoto()
{
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
var file = await KnownFolders.PicturesLibrary.CreateFileAsync("Photo.jpg", CreationCollisionOption.ReplaceExisting);
await takePhotoManager.CapturePhotoToStorageFileAsync(imgFormat, file);
}
Run Code Online (Sandbox Code Playgroud)预习
<CaptureElement x:Name="PhotoPreview" FlowDirection="LeftToRight"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="UniformToFill">
</CaptureElement>
Run Code Online (Sandbox Code Playgroud)我有两个问题:1.预览不会填满整个空间


谢谢
我有一个div.content,里面有30个div(div.blocks)
我想制作一个动画div.blocks来到他们自己的位置.
例如:
CSS
.content{
position:absolute;
background:gray;
width:100%;
height:100%;
}
.blocks{
display:inline-block;
position:absolute;
background:wheat;
color:gray;
font-size:large;
width:50px;
height:50px;
margin-top:4px;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div class="content">
<div class="blocks" data-number="0">1</div>
<div class="blocks" data-number="1">2</div>
<div class="blocks" data-number="2">3</div>
<div class="blocks" data-number="3">4</div>
<div class="blocks" data-number="4">5</div>
<div class="blocks" data-number="5">6</div>
<div class="blocks" data-number="6">7</div>
<div class="blocks" data-number="7">8</div>
<div class="blocks" data-number="8">9</div>
<div class="blocks" data-number="9">10</div>
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的
$(function(){
// [0][0]==top
// [0][1]=right
var positions=[
[10,10],
[10,64],
[10,118],
[10,172],
[10,226],
[64,10],
[64,64],
[64,118],
[64,172],
[64,226]
];
$( …Run Code Online (Sandbox Code Playgroud) 我通过逐行逐步执行代码找不到问题.
我设法从代码库中提取了一个最小的例子,它归结为以下几行.代码的作用是从对象读取3D点云,将其包装到共享指针中并使用QT的信号引擎将其发送出去.中间的两行导致错误:
for(vector<Package>::iterator resit = results.begin(); resit != results.end(); resit++) {
// [..] Code ommitted
pcl::PointCloud<pcl::PointXYZ> c = queryObject.getCloud();
// The Ptr typedef resolves to boost::shared_ptr<PointCloud<PointT>>
// (1) Does not work:
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr(&c);
// (2) Works:
//pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr(new pcl::PointCloud<pcl::PointXYZ>);
emit this->cluster_added(cloud_ptr);
}
// The error always happens AFTER the FIRST iteration
Run Code Online (Sandbox Code Playgroud)
当我在(2)中发表评论(当然评论出(1)时),代码有效.在这两个版本中cloud_ptr都是一个携带云的共享指针 - 除了第一次它是一个填充的云而不是第二个版本的事实.
编辑:既然你们指出了 - 我看到当前版本搞砸了.这是无意义的试用的结果.最初,该getCloud()方法返回了指向云的指针.但那个版本也不起作用.这是代码的原始版本:
for(vector<Package>::iterator resit = results.begin(); resit != results.end(); resit++) {
// [..] Code ommitted
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr(queryObject.getCloud());
emit this->cluster_added(cloud_ptr);
} …Run Code Online (Sandbox Code Playgroud) 我有最简单的数学问题,我无法弄明白(可能整天都在工作累了).这很简单,我循环浏览项目并希望显示最终价格而不需要税等等.问题是我的数学是正确的,但是当我显示价格时,所有项目都具有相同的值(值最后一项).据我所知,每次循环时总变量都在变化,最后一个循环显示最后一个值.如何解决?
public function getTotal($items)
{
$total;
foreach($items as $item){
$total = $item->getPrice() - $item->getDiscount() + $item->getValue();
}
return $total;
}
Run Code Online (Sandbox Code Playgroud)
它应该显示:
Item1: 154
Item2: 77
Run Code Online (Sandbox Code Playgroud)
它显示:
Item1:77
Item2:77
Run Code Online (Sandbox Code Playgroud)