
C++
面向对象World
用不同的思维方式看自己
展开
-
C++数组声明的数组长度是变量也行?
程序能正常运行,打印的data size还是对的...,怎么解释?原创 2022-11-23 18:57:07 · 633 阅读 · 0 评论 -
linux Framebuffer 8bpp画图双缓冲实现
Framebuffer画图原创 2022-10-17 18:19:22 · 960 阅读 · 0 评论 -
rapidjson读写json文件
rapidjson读写json文件原创 2022-06-23 17:18:31 · 1621 阅读 · 0 评论 -
C++的clog到底有没有被缓冲?
先看cout#include <iostream>#include <unistd.h>int main(){ std::cout << "this is cout"; while(1) { sleep(3); } return 0;}结果:什么都不会输出再看cerr将上面代码,换成:std::cerr << "this is cerr";结果:直接输出再看clog将上面代码,换成:std::c原创 2022-04-10 20:52:43 · 916 阅读 · 0 评论 -
.so共享动态库文件内部的‘节‘
360压缩打开后,此文件分了很多节:原创 2022-04-10 11:48:29 · 261 阅读 · 0 评论 -
颜色转换RRRGGGBBB->RGBRGBRGB
// RRRGGGBBB->RGBRGBRGB u8 *rgb = new u8[yuv2rgb_mem.size]; int index = 0; int h = yuv_info.yuv_cap->height; int w = yuv_info.yuv_cap->width; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) ...原创 2022-04-03 17:25:31 · 27668 阅读 · 0 评论 -
深度学习算法移植工作内容简介
模型可用性检查 模型转换 模型准确性验证 代码移植 代码修正 配置编译项 编译 部署应用到目标终端 执行 调试 重复5-10 完毕原创 2022-03-16 16:25:42 · 1146 阅读 · 0 评论 -
C++读取float数据文件内容
#include <iostream>#include <vector>#include <fstream>using namespace std;/** * 读取文件数据到vector中 * * @param file_name 文件名 */std::vector<float> read_file(const std::string &file_name){ int begin, end; std::ifs.原创 2022-03-10 17:50:13 · 1082 阅读 · 0 评论 -
左值、左结合、右结合
左值是有存储空间、且值可改变的数据对象例如,变量,数组的元素,结构体的成员,引用变量赋值语句的左边必须是左值左结合:从左往右计算a+b+c右结合:从右往左计算a=b=c=0 ...原创 2022-03-08 17:07:57 · 256 阅读 · 0 评论 -
位运算符简记
&,与0&0=0, 0&1=0, 1&0=0, 1&1=1全1为1|,或0&0=0, 0&1=0, 1&0=0, 1&1=1 有1为1^,异或0&0=0, 0&1=0, 1&0=0, 1&1=1不同为1~,取反 ~0=1,~1=0...原创 2022-03-08 09:58:39 · 110 阅读 · 0 评论 -
C++全局变量使用
#include "aa.h"bool isrunning = true; //定义全局变量int main(){ Aa aa; aa.speak(); return 0;}#pragma onceextern bool isrunning; //声明已定义过的全局变量class Aa{public: void speak();};#include "aa.h"#include <iostream>void Aa::spe.原创 2022-03-07 10:28:37 · 1654 阅读 · 0 评论 -
easylogging禁止生成默认的myeasylog.log文件
在easyloggingplus.cpp中增加一个宏定义:#define ELPP_NO_DEFAULT_LOG_FILE原创 2022-02-25 09:07:41 · 1349 阅读 · 0 评论 -
easylogging简单使用示例
测试版本:v9.97.0从官网下载easylogging++.h和easylogging++.cc文件easyloggingpp/src at master · amrayn/easyloggingpp · GitHub原创 2022-02-22 17:46:25 · 1087 阅读 · 0 评论 -
C++局部对象变量默认初始化
会自动调用默认构造函数进行初始化(不论变量在哪里定义)原创 2022-01-27 11:40:52 · 614 阅读 · 0 评论 -
VSCode Linux下找不到头文件
现象:处理:(让vscode知道到哪找头文件)在.vscode文件夹(找你自己的)下创建文件:c_cpp_properties.json{ "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/**" ], "defines": [..原创 2021-11-11 19:30:03 · 4096 阅读 · 3 评论 -
C++读取二进制文件
/** * 读取文件数据到vector中 * 正常的RGB文件 * @param file_name 文件名 */ std::vector<uint8_t> read_file(const std::string &file_name) { int begin, end; std::ifstream file(file_name, std::ios::in | std::ios::binary); .原创 2021-09-07 17:36:48 · 1695 阅读 · 0 评论 -
C++按行读取文件
原创 2021-09-01 14:22:33 · 1038 阅读 · 0 评论 -
C++ 图像预处理之Padding
//720*1280的图片,宽度padding到1280,两侧补0 uint8_t file_bytes_padding[1280 * 1280 * 3]; memset(&file_bytes_padding, 0, sizeof(file_bytes_padding)); for (int i = 0; i < 1280; i++) //行 { // for (int j = 0; j < 1280; j+...原创 2021-08-31 09:45:33 · 1076 阅读 · 0 评论 -
C++ TensorflowLite模型验证
故事是这样的:有一个手撑检测的tflite模型,需要在开发板上跑起来。手机版本的已成熟,要移植到开发板上。现在要验证tflite模型文件在板子上的运行结果要和手机上一致。记录下Android版API运行推理前的图片数据文件(经过了规一化处理,所以都是-1~1之间的float数据) 这一步卡在了写float数据到二进制文件中,C++读出来有问题 换了个方案,直接存储float字符串 private void saveFile(float[] pfImageData) {原创 2021-08-25 18:39:56 · 1478 阅读 · 0 评论 -
C++打印二维数组、三维数组
#include <iostream>using namespace std;int main(){ float anchors[5][4] = {0}; //输出 for (float(&p)[4] : anchors) { for (float &q : p) { cout << q << ' '; } cout <.原创 2021-07-27 15:34:02 · 2724 阅读 · 0 评论 -
Android Java代码移植翻译为C++笔记
JAVA C++ 接口定义 interface ClassName { void method(); } class ClassName { virtual ~ClassName() = default virtualvoid method()=0; } 数组定义 public int[][] arr = new int[2][2]; ......原创 2021-07-21 10:36:31 · 409 阅读 · 2 评论 -
C++操作符优先级
if (fd_cavalry = open(CAVALRY_DEV_NODE, O_RDWR, 0) < 0) { LogUtil::log("cavalry_dev_node open error"); return -1; }上面的代码会出现什么问题?fd_cavalry这个变量未被赋值!原因就是=的优先级小于<需要修改一下,加个()if((fd_cavalry=open(CAVALRY_DEV_NODE,...原创 2021-05-24 15:23:55 · 163 阅读 · 0 评论 -
C++监听者处理线程回调
上图中的yuv_capturer的定义如果在AlarmManager::init()函数中,那回调是无法触发的;因为init()执行结束后,yuv_capturer即被销毁,yuv_capturer.setListener()传进去的指针也会消失。没有了监听者,就无法调用回调了。应该按上图的方式,将yuv_capturer的定义放到构造中。...原创 2021-04-23 15:46:08 · 512 阅读 · 0 评论 -
C scandir 对Linux文件目录排序
int datesort(const struct dirent **file1, const struct dirent **file2){ struct stat info1, info2; string file1_name((*file1)->d_name); string file2_name((*file2)->d_name); stat(("/sdcard/mmcblk0p1/" + file1_name).c_str(), &inf.原创 2021-02-26 11:20:10 · 1630 阅读 · 0 评论 -
Linux C 格式化SD卡
//若不存在/sdcard/mmcblk0p1 (这是本系统自己挂载的目录) if (access("/sdcard/mmcblk0p1", 0) == -1) { system("mkfs -t vfat /dev/mmcblk0p1"); printf("格式化了,重启...\n"); sleep(5); ...原创 2021-02-25 09:48:09 · 915 阅读 · 0 评论 -
C++结构体大小
空结构体大小为1非空结构体大小为每个成员的大小之和原创 2021-01-18 15:50:32 · 613 阅读 · 0 评论 -
C++的声明、定义、初始化
int a = 0;//定义int a; //声明a = 20; //初始化原创 2021-01-18 15:24:13 · 327 阅读 · 0 评论 -
C++ ()和[]错误引发的血灾memory corruption
//读取文件发送 ifstream infile; infile.open(path, ios::in | ios::binary); if (!infile.is_open()) { WsLogUtil::log("file open fail: %s", path); return; } infile.seekg(0, infile.end); int file_length = infile.tellg(...原创 2021-01-06 11:35:01 · 664 阅读 · 0 评论 -
指针变量和常量面试题
如下文件Hello.c#include <stdio.h>int main(){ const int a = 10; int *p = (int *)&a; *p = 20; printf("a=%d, *p=%d\n", a, *p); return 0;}结果:a=20 *p=20如果文件名是Hello.cpp,则结果是a=10 *p=20上面两种情况的编译用的是gcc Hello.xx说明gcc对...原创 2020-12-15 13:30:34 · 247 阅读 · 0 评论 -
Makefile从当前目录的上一层开始找文件
#target PC or Board Default is haisi platformCURDIR := $(shell pwd)TG = TESTPARENTDIR := ../# CURDIR 和 TG是定义的变量# 引用变量采用"$(变量名)"# Makefile中的变量只能是字符串类型# Makefile中变量有四种赋值方式:# 1,简单赋值( := ) 编程语言中常规理解的赋值方式,只对当前语句的变量有效# 2,递归赋值( = ) 赋值语句可能影响多个变量,所有目标.原创 2020-11-26 19:16:44 · 3404 阅读 · 1 评论 -
cannot declare parameter ‘listener‘ to be of abstract type
AttachmentMessageManager::AttachmentMessageManager(/* args */){}AttachmentMessageManager::~AttachmentMessageManager(){}void AttachmentMessageManager::setAttachmentListener(IAttachmentListener listener){ this->m_attachment_listener = listen.原创 2020-11-17 17:25:17 · 892 阅读 · 0 评论 -
Linux系统下的C++在类中启动线程
#include "mdvr_communication.h"#include <thread>#include <unistd.h>MDVRCommunication::MDVRCommunication(){ CommonUtil::show_text("MdvrCommunication created");}MDVRCommunication::~MDVRCommunication(){ CommonUtil::show_text("Mdvr.原创 2020-11-06 19:37:20 · 761 阅读 · 0 评论 -
C++ C语言Socket库Libevent的粘包处理
void MDVRConnectClient::on_read(struct bufferevent *bev, void *user_data){ //获取输入缓冲区中的数据(数据未移走) struct evbuffer *input = bufferevent_get_input(bev); size_t content_size = evbuffer_get_length(input); if (content_size > 0) { .原创 2020-11-04 16:52:59 · 1309 阅读 · 0 评论 -
Makefile编写&运行
#target PC or Board Default is haisi platformCURDIR := $(shell pwd)TG=Communication# ifndef TG# TG=PC # else# TG=HI# endif#targetOUTOBJ = out/objBIN = mapa3_$(TG)MAKE = makeMKDIR = mkdirRM = rmINCLUDES += -I$(CURDIR)/ -O3# CC=arm-him.原创 2020-10-16 16:05:40 · 2100 阅读 · 0 评论 -
Linux C语言 Socket通信 Libevent
#include <string.h>#include <errno.h>#include <stdio.h>#include <signal.h>#include <netinet/in.h>#include <arpa/inet.h>#include <sys/socket.h>#include <event2/bufferevent.h>#include <event2/buffe.原创 2020-09-09 17:21:58 · 340 阅读 · 0 评论 -
海思linux板子上跑Libevent过程记录
1、libevent下载源码 https://github.com/libevent/libevent github下载libevent.zip,放到vscode的linux docker中 2、libevent海思编译器下执行编译安装操作 ./configure ./configure --prefix=/usr/local/libevent --host=arm-linux CC=arm-himix200-linux-gcc --enable-shared --enable-stat.原创 2020-09-09 14:25:13 · 344 阅读 · 0 评论 -
C和C++基础概念
标题 名称 备注 .a 静态库 在程序编译时会被链接到目标代码中 编译之后程序文件大,但加载快,隔离性也好 .so 动态库 在程序编译时并不会被链接到目标代码中 在程序运行是才被载入 多个应用程序可以使用同一个动态库 -shared 用于生成动态库 指针 内存地址 ...原创 2020-09-09 11:03:54 · 226 阅读 · 0 评论