小编bat*_*man的帖子

为什么我的 iOS 应用程序不请求用户访问相机的权限?

我开发 iOS 应用程序,它使用相机。AVCaptureDeviceInput 用于与相机连接。我检查了授权状态为

- (void)checkDeviceAuthorizationStatus
{
    NSString *mediaType = AVMediaTypeVideo;

    [AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
        if (granted)
        {
            //Granted access to mediaType
            [self setDeviceAuthorized:YES];
        }
        else
        {
            //Not granted access to mediaType
            dispatch_async(dispatch_get_main_queue(), ^{
                [[[UIAlertView alloc] initWithTitle:@"AVCam!"
                                            message:@"AVCam doesn't have permission to use Camera, please change privacy settings"
                                           delegate:self
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil] show];
                [self setDeviceAuthorized:NO];
            });
        }
    }];
}
Run Code Online (Sandbox Code Playgroud)

当我启动应用程序时,为什么它不询问用户访问相机的权限?因此该应用程序不会出现在设置/隐私/相机中以手动允许访问相机。然后显示此错误"AVCam doesn't have permission to use Camera, please change privacy settings"并且应用程序无法使用相机。

编辑:这意味着未经用户许可,应用程序不得访问相机。不仅是相机,相机胶卷也存在同样的问题。

所有这些事情都是在我在“设置/重置/恢复所有设置”中重置设置后发生的。在此之前,该应用程序运行良好。

ios avcapturesession avcapturedevice avcam

6
推荐指数
1
解决办法
1万
查看次数

通过代码定位具有锚定预设的UI元素

当我们在定位统一的UI元素,我们从固定锚预设的位置,因此它的位置是否正确放置在画布上.

在此输入图像描述

我们选择顶部,中部,底部,拉伸和蓝色点.

如果我在C#中的代码中创建UI元素,我怎么能做同样的事情?

我做

Texture2D textureWhite = new Texture2D(1, 1);
textureWhite.SetPixel(0, 0, Color.white);
textureWhite.Apply(); 
Run Code Online (Sandbox Code Playgroud)

如何将左上角与蓝色点一起修复?

c# unity-game-engine unity3d-2dtools

6
推荐指数
1
解决办法
3733
查看次数

unity scrollview 无法滚动到最后

我有一个滚动视图。水平和垂直滚动条被删除,因为它很丑,而且我有空间限制。

当我将项目填充到滚动视图的内容中时,如图所示 在此处输入图片说明

我不能滚动。视图正在移动但不滚动。当我滚动时,只需滚动到一定程度并滚动回原始位置。

可能有什么问题?

在此处输入图片说明

unity-game-engine unity3d-2dtools

6
推荐指数
1
解决办法
1万
查看次数

Json::Value::resolveReference(key, end):需要 objectValue

使用 jsoncpp,我正在创建一个 JSON 对象。

   Json::Value root;   
   Json::Value zone1;
   Json::Value coord;
   Json::Value gridOrigin;
   
   JSON_PEOPLE(){
     zone1["zoneID"] = "shop1";
     zone1["stamp"] = "##########";
     zone1["gridSizeX"]=50;
     zone1["gridSizeY"]=50;
     zone1["gridScale"]=0.5;
     zone1["gridOrigin"].append(28.5);
     zone1["gridOrigin"].append(20.6);
   }
   
   std::string get_time_stamp()
   {
      time_t rawtime;
      std::time(&rawtime);
      struct tm *tinfo = std::localtime(&rawtime);
      char buf[50];
      strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tinfo);
      return std::string(buf);   

   }
   std::string updateZone (std::vector < std::pair <int,int> >  &world_coords){ 
      zone1["stamp"]=get_time_stamp(); 
      coord.clear();
      zone1["detected_people"].clear();
      for(int i=0; i < world_coords.size(); i++){
         Json::Value person;        
         person.append(world_coords[i].first);person.append(world_coords[i].second);
         coord["coordinates"].append(person);
      }
      zone1["detected_people"] = coord;
      root["zone1"]=zone1;
      Json::StreamWriterBuilder builder;
      const std::string json_file = Json::writeString(builder, root); …
Run Code Online (Sandbox Code Playgroud)

json jsoncpp

6
推荐指数
0
解决办法
3366
查看次数

测试OpenCV中的parallel_for_性能

我parallel_for_ 通过与简单的数组求和和乘法的正常操作进行比较,在OpenCV中进行了测试.

我有100个整数的数组,并分成10个并运行使用parallel_for_.

然后我也有正常的0到99运算进行求和和多重复用.

然后我测量了经过的时间,正常操作比parallel_for_ 操作更快.

我的CPU是Intel(R)Core(TM)i7-2600 Quard核心CPU. parallel_for_为了求和,操作耗时0.002秒(需要2个时钟周期),乘以0.003秒(耗时3个时钟周期).

但是对于求和和乘法,正常操作需要0.0000秒(少于一个单击周期).我错过了什么?我的代码如下.

TEST类

#include <opencv2\core\internal.hpp>
#include <opencv2\core\core.hpp>
#include <tbb\tbb.h>
using namespace tbb;
using namespace cv;

template <class type>
class Parallel_clipBufferValues:public cv::ParallelLoopBody
{
   private:
       type *buffertoClip;
       type maxSegment;

       char typeOperation;//m = mul, s = summation
       static double total;
   public:
       Parallel_clipBufferValues(){ParallelLoopBody::ParallelLoopBody();};
       Parallel_clipBufferValues(type *buffertoprocess, const type max, const char op): buffertoClip(buffertoprocess), maxSegment(max), typeOperation(op){ 
           if(typeOperation == 's')
                total = 0; 
           else if(typeOperation == 'm')
                total = 1; 
       }
       ~Parallel_clipBufferValues(){ParallelLoopBody::~ParallelLoopBody();};

       virtual void …
Run Code Online (Sandbox Code Playgroud)

c++ parallel-processing performance opencv

5
推荐指数
1
解决办法
3112
查看次数

autoreconf:需要“configure.ac”或“configure.in”

我按照说明安装FB 机器学习工具。

库安装说明之一是

cd ~/libraries
git clone https://github.com/facebook/folly.git
cd folly/folly/
autoreconf -ivf
./configure
cp -R ~/libraries/gtest-1.7/* ./test/gtest-1.7/
make
make check
sudo make install
sudo ldconfig # reload the lib paths after freshly installed folly. fbthrift needs it.
Run Code Online (Sandbox Code Playgroud)

我遇到问题autoreconf -ivf,错误是

autoreconf: 'configure.ac' or 'configure.in' is required
Run Code Online (Sandbox Code Playgroud)

但是当我安装 autoreconf 时,我拥有最新版本。

autoconf is already the newest version (2.69-9).
0 upgraded, 0 newly installed, 0 to remove and 26 not upgraded.
Run Code Online (Sandbox Code Playgroud)

可能出什么问题了?

configure autoreconf

5
推荐指数
1
解决办法
4万
查看次数

如何仅使用一个 GPU 进行 tensorflow 会话?

我有两个 GPU。我的程序使用 TensorRT 和 Tensorflow。

当我只运行 TensorRT 部分时,没问题。当我与 Tensorflow 部分一起运行时,出现以下错误

[TensorRT] ERROR: engine.cpp (370) - Cuda Error in ~ExecutionContext: 77 (an illegal memory access was encountered)
terminate called after throwing an instance of 'nvinfer1::CudaError'
  what():  std::exception
Run Code Online (Sandbox Code Playgroud)

问题是当 Tensorflow 会话开始时如下

self.graph = tf.get_default_graph()
self.persistent_sess = tf.Session(graph=self.graph, config=tf_config)
Run Code Online (Sandbox Code Playgroud)

它将两个 GPU 加载为

2019-06-06 14:15:04.420265: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6965 MB memory) -> physical GPU (device: 0, name: Quadro P4000, pci bus id: 0000:04:00.0, compute capability: 6.1)
2019-06-06 14:15:04.420713: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] …
Run Code Online (Sandbox Code Playgroud)

python cuda tensorflow tensorrt

5
推荐指数
1
解决办法
2673
查看次数

如何知道 Pytorch 模型的输入/输出层名称和大小?

我有 Pytorch model.pth 使用Detectron2 的COCO 对象检测基线预训练模型 R50-FPN。我正在尝试转换.pth model to onnx.

我的代码如下。

import io
import numpy as np

from torch import nn
import torch.utils.model_zoo as model_zoo
import torch.onnx
from torchvision import models

model = torch.load('output_object_detection/model_final.pth')
x = torch.randn(1, 3, 1080, 1920, requires_grad=True)#0, in_cha, in_h, in_w
torch_out = torch_model(x)
print(model)
torch.onnx.export(torch_model,               # model being run
                  x,                         # model input (or a tuple for multiple inputs)
                  "super_resolution.onnx",   # where to save the model (can be a file or file-like …
Run Code Online (Sandbox Code Playgroud)

python pytorch onnx onnxruntime

5
推荐指数
1
解决办法
8949
查看次数

cv::bitwise_not 位于 cv::Mat 矩阵上

我尝试将 cv::bitwise_not 转换为双值的 cv::Mat 矩阵。我申请了像

cv::bitwise_not(img, imgtemp);
Run Code Online (Sandbox Code Playgroud)

img是CV_64F0和1的数据。但是imgtemp里面全是无意义的数据。我期望 0 inimg为 1 at imgtemp,1 inimg为 0 at imgtemp。如何将 bitwise_not 应用于双 Mat 矩阵?谢谢

opencv

4
推荐指数
1
解决办法
5961
查看次数

OpenCV中的cornerSubPix:目的和应用

我试图了解cornerSubPixOpenCV中的API,因为它背后的想法和实用性.我阅读了链接中的解释,无法理解它是如何工作的以及它是如何有用的.有人可以解释一下它是如何工作的以及它在角落细化中的用途吗?我检查了我的角点检测应用程序没有cornerSubPix和用cornerSubPix.输出图像没有太大差异,但处理需要时间.谢谢

opencv image-processing

4
推荐指数
1
解决办法
3226
查看次数