1. DFrame使用方法

std::unique_ptr<deptrum::Frame> MakeFrame(deptrum::FrameType frame_type,int width,int height,int bytes_per_pixel,void* data,uint64_t timestamp,int index,float temperature) {std::unique_ptr<deptrum::Frame> frame{std::make_unique<deptrum::Frame>()};
​frame->index = index;frame->size = width * height * bytes_per_pixel;frame->data = data;frame->timestamp = timestamp;frame->frame_type = frame_type;frame->temperature = temperature;frame->rows = height;frame->cols = width;frame->bytes_per_pixel = bytes_per_pixel;return frame;
}
std::unique_ptr<deptrum::Frame> MakeFrame(deptrum::FrameType frame_type,int width,int height,int bytes_per_pixel,void* data,uint64_t timestamp = 0,int index = 0,float temperature = 0);
​
}  // namespace depth
struct DFrame : public Frame {DFrame(){};DFrame(int rows, int cols, int bytes_per_pixel, FrameType frame_type, void* data) {this->index = 0;this->size = rows * cols * bytes_per_pixel;this->cols = cols;this->rows = rows;this->bytes_per_pixel = bytes_per_pixel;this->temperature = 0;this->frame_type = frame_type;this->timestamp = 0;this->data = data;}DFrame(int rows, int cols, int bytes_per_pixel, FrameType frame_type) {this->index = 0;this->size = rows * cols * bytes_per_pixel;this->cols = cols;this->rows = rows;this->bytes_per_pixel = bytes_per_pixel;this->temperature = 0;this->frame_type = frame_type;this->timestamp = 0;this->data = new uint8_t[size];}void FreeData() {if (data) {delete[](uint8_t*) data;data = nullptr;}}~DFrame() {
//    if (data&&flag) {
//        delete[](uint8_t*) data;
//        data = nullptr;
//    }
// private flag;
};
void MainWindow::on_pushButton_clicked(bool checked)
{int32_t  status=0;
​//1.初始化深度库DepthMagic* deptrum_depth = nullptr;deptrum_depth = DepthMagic::Create(DepthInputFormat::kUint8);
​DeviceType device_type = DeviceType::kAurora300;if (deptrum_depth->Initialize(FLAGS_config, device_type, 2) != 0) {if(deptrum_depth)DepthMagic::Destroy(deptrum_depth);return;}
​//2.读图cv::Mat speckle_image = cv::imread(path_speckle, cv::IMREAD_ANYDEPTH);cv::Mat ir_image=cv::imread(path_ir, cv::IMREAD_ANYDEPTH);cv::transpose(ir_image, ir_image);cv::flip(ir_image, ir_image, 0);cv::resize(ir_image, ir_image, cv::Size(image_output_width_, image_output_height_));
​//3.预处理uint8_t* blurred = new uint8_t[image_input_width_ * image_input_height_];uint8_t* flagged = new uint8_t[image_input_width_ * image_input_height_];Frame *blurred_frame=new Frame;   blurred_frame->data=blurred;Frame* flagged_frame=new Frame;   flagged_frame->data=flagged;
​std::shared_ptr<deptrum::Frame> blu_share(blurred_frame,[blurred](deptrum::Frame* blurred_frame) {delete[] blurred;delete blurred_frame;});std::shared_ptr<deptrum::Frame> flg_share(flagged_frame,[flagged](deptrum::Frame* flagged_frame) {delete[] flagged;delete flagged_frame;});status = deptrum_depth->Preprocess(blu_share.get(),flg_share.get(),MakeFrame(deptrum::FrameType::kSpeckleFrame,1280,800,1,speckle_image.data).get());std::cout << "Preprocess status :" << status << std::endl;
​
​//4.深度重建uint16_t depth_roi_mean = 0;uint16_t* depth_image = new uint16_t[400 * 640];status = deptrum_depth->GenerateDepthMap(depth_image,depth_roi_mean,blu_share.get(),MakeFrame(deptrum::FrameType::kIrFrame,400,640,1,ir_image.data).get(),flg_share.get(),1);
​std::cout << "GenerateDepthMap status" << status << std::endl;cv::Mat raw_depth(640, 400, CV_16UC1, depth_image);cv::imwrite("D:\\depthrun\\untitled1\\release\\depth.png", raw_depth * 100);delete[] depth_image;speckle_image.release();ir_image.release();if(deptrum_depth)DepthMagic::Destroy(deptrum_depth);
​
}

【Smart_Point】unique_ptr中独占指针使用MakeFrame相关推荐

  1. 【Smart_Point】C/C++ 中独占指针unique_ptr

    1. 独占指针unique_ptr 目录 1. 独占指针unique_ptr 1.1 unique_ptr含义 1.2 C++11特性 1.3 C++14特性 1.1 unique_ptr含义 uni ...

  2. 【Smart_Point】C/C++ 中智能指针

    C++11智能指针 目录 C++11智能指针 1.1 C++11智能指针介绍 1.2 为什么要使用智能指针 1.2.1 auto_ptr(C++98的方案,C++11已经抛弃)采用所有权模式. 1.2 ...

  3. 【Smart_Point】C/C++ 中共享指针 shared_ptr

    1. 共享指针 shared_ptr 目录 1. 共享指针 shared_ptr 1.1 共享指针解决的问题? 1.2 创建 shared_ptr 对象 1.3 分离关联的原始指针 1.4 自定义删除 ...

  4. C++中智能指针详解

    1.问题引入 在C++中,静态内存和栈内存外,还有一部分内存称为堆程序用堆来存储动态分配的对象即那些在程序运行时分配的对象,当动态对象不再使用时,我们的代码必须显式的销毁它们.在C++中一般使用&qu ...

  5. C++中智能指针的原理、使用、实现

    C++中智能指针的原理.使用.实现 转自:https://www.cnblogs.com/wxquare/p/4759020.html 1 智能指针的作用 C++程序设计中使用堆内存是非常频繁的操作, ...

  6. DIRECTX中独占模式与窗口模式的切换(译)

    <script language="javascript" type="text/javascript">document.title=" ...

  7. java unsafe获取指针_【实战Java高并发程序设计 1】Java中的指针:Unsafe类

    是<实战Java高并发程序设计>第4章的几点. 如果你对技术有着不折不挠的追求,应该还会特别在意incrementAndGet() 方法中compareAndSet()的实现.现在,就让我 ...

  8. 某内存池中的指针用法

    内存池实现有许多种,各有不同的优缺点. 这里不是主要说内存池,只是觉得这个内存池中的指针用得很飘逸! template <class T,int AllocSize = 50> class ...

  9. c语言中程序偏离,C语言中的指针加减偏移量

    首先看一段程序: #include int main() { int a[5] = {1, 2, 3, 4, 5}; int* p = (int*)(&a + 1); printf(" ...

最新文章

  1. 临床研究中的基因组学、药物基因组学、蛋白质组学和转录组学 Omics in Clinical Practice: Genomics, Pharmacogenomics, Proteomics, and
  2. 浅析MongoDB数据库的海量数据存储应用
  3. 2011目标 及 总结
  4. .NET混淆器 Dotfuscator如何保护应用程序?控制流了解一下!
  5. 基于线性筛的Pollard_rho 因数分解算法【例题】
  6. ac3168无线网卡驱动下载_计算机基础:网卡
  7. [NOI2015]寿司晚宴——状压dp
  8. Google Code Review 如何编写代码评论
  9. 华为人均工资高达70万,但先看看华为员工的16项标准
  10. SDRAM-高手进阶,终极内存技术指南----学习笔记
  11. SylixOS的来龙去脉
  12. iOS PayPal集成和使用
  13. BTC钱包(wallet.dat 文件密码与私钥的区别)
  14. tbf格式用什么打开_TBF的完整形式是什么?
  15. 面试之HashMap与HashTable
  16. Unity3D学习记录——NGUI Sprit3
  17. 制作系统盘并且重装系统
  18. JavaScript面试题整理汇总
  19. 酷狗外链播放器html5,仿酷狗html5手机音乐播放器主要部分代码
  20. M3u8播放器,可在线搜索

热门文章

  1. rpm方式安装mysql5.7.24_linux centOS 7安装mysql 5.7.24
  2. 百度云加速 ajax,使用百度云加速后网站打开速度慢、广告不显示的解决方法
  3. puml绘制思维导图_如何用ProcessOn画出漂亮的思维导图
  4. sql列转行函数oracle,SQL列转行
  5. 一文看懂docker容器技术架构及其中的各个模块
  6. 机器学习中的梯度下降( Gradient Descent)算法
  7. 树莓派/PC实现实时摄像头数据共享(Python—OpenCV)
  8. Windows下修改jupyter默认工作路径教程
  9. 【Relax人生法则之躺平方法论】那些看似无足轻重 实则细思极恐的毒鸡汤
  10. vue3启动项目时,自动打开浏览器怎么配置?