HuiHut

专业修电脑,副业补衣服。


  • 首页

  • 归档

  • 标签

  • 关于

  • 搜索

VSCode 的 C/C++ 调试环境的 launch.json、 tasks.json 文件

发表于 2018-06-12 | 分类于 CS

launch.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Configuring tasks.json for C/C++ debugging
// author: huihut
// repo: https://gist.github.com/huihut/9548fe7e1084cf8e844120c5668b8177

// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process

{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"preLaunchTask": "build",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}]
}
阅读全文 »

C++ 调用 Python 模块

发表于 2018-06-12 | 分类于 CS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// C++ call Python module 
// author: huihut
// repo: https://gist.github.com/huihut/b4597d097123a8c8388c71b3f0ff21e5

#include <iostream>
#include <Python.h>

// C++ call Python module
bool CppCallPython()
{
// Python initialize
Py_Initialize();
if (!Py_IsInitialized())
{
std::cout << "Python initialization failed!\n";
return false;
}

// If my MyPython.py file is in "/Users/xx/code", set the working path to "/Users/xx/code"
std::string path = "/Users/xx/code";
PySys_SetPath(&path[0u]);

// Import MyPython.py module
PyObject* pModule = PyImport_ImportModule("MyPython");
if (!pModule)
{
std::cout <<"Cannot open Python file!\n";
return false;
}

// Get the HelloPython() function in the module
PyObject* pFunhello = PyObject_GetAttrString(pModule, "HelloPython");
if (!pFunhello)
{
std::cout << "Failed to get this function!";
return false;
}

// Call HelloPython()
PyObject_CallFunction(pFunhello, NULL);

// Finalize
Py_Finalize();

return true;
}

C++ 使用 Qt 生成带标签数据集的 CSV 文件

发表于 2018-06-12 | 分类于 CS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// C++ 使用 Qt 生成 CSV 文件
// 以下函数实现生成特定类型的 CSV 文件,可用于生成带标签的数据集 CSV 文件,标签为图片上一级的文件夹名字。
// 作者:huihut
// 仓库:https://gist.github.com/huihut/c9f43e276ef7652f0471725482a1e4f6

/*

目录结构(使用 tree 命令查看):

xx@xxs-MacBook-Pro:~/code/dataset$ tree
.
├── README
├── dataset_csv.txt
├── s01
│ ├── 01.pgm
│ ├── ...
│ └── 10.pgm
├── s02
│ ├── 01.pgm
│ ├── ...
│ └── 10.pgm
...
└── s10
├── 01.pgm
├── ...
└── 10.pgm

-----------------------------------------------------------

生成的 CSV 文件内容(使用 cat 命令查看 dataset_csv.txt 文件内容):

xx@xxs-MacBook-Pro:~/code/dataset$ cat dataset_csv.txt
/Users/xx/code/dataset/s01/01.pgm,s01
/Users/xx/code/dataset/s01/02.pgm,s01
...
/Users/xx/code/dataset/s01/10.pgm,s01
/Users/xx/code/dataset/s02/01.pgm,s02
/Users/xx/code/dataset/s02/02.pgm,s02
...
/Users/xx/code/dataset/s10/01.pgm,s10
/Users/xx/code/dataset/s10/02.pgm,s10
...
/Users/xx/code/dataset/s10/10.pgm,s10

*/


#include <QDir>
#include <QDebug>
#include <QDirIterator>

bool CreateCSV()
{
// 数据集的基础路径
QString datasetdir = "/Users/xx/code/dataset";

// 生成的 CSV 文件的名字
QString csvName = "dataset_csv.txt";

// 数据集路径与数据集名字的分隔符
char separator = ',';

// 数据集路径、数据集名字
QString datasetPath, datasetName;

// 文件迭代器:获取指定类型(以下是 pgm、png、jpg 三种类型)的数据集文件
QDirIterator it(datasetdir, QStringList() << "*.pgm" << "*.png" << "*.jpg", QDir::Files, QDirIterator::Subdirectories);
if(!it.hasNext())
{
qDebug() << "当前路径下数据集为空!\n";
return false;
}

// 创建及打开 CSV 文件
QFile file(datasetdir + QDir::toNativeSeparators("/") + csvName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
qDebug() << "打开 CSV 文件失败!\n";
return false;
}
// 文件写的文本流
QTextStream csv_ts(&file);

// 文件迭代器中有指定数据集文件则依次迭代
while (it.hasNext())
{
// 数据集路径
datasetPath = it.next();
// 数据集名字
datasetName = datasetPath.section(QDir::toNativeSeparators("/"), -2, -2);
// 写入文本流
csv_ts << datasetPath << separator << datasetName << "\n";
}
// 关闭文本流
file.close();

return true;
}

Qt GDB 无法调试 MSVC 编译的程序而报错:file format not recognized

发表于 2018-06-02 | 分类于 CS

环境

  • Windows 10 x64
  • Visual Studio 2017
  • Qt 5.11

异常

Qt Debug 时提示异常:

1
qt not in executable format. file format not recognized
阅读全文 »

一加 3T ROM、内核、固件、Recovery、框架、软件(APP)总结

发表于 2018-05-11 | 分类于 CS

一加 3T ROM、内核(Kernel)、固件(Firmware)、Recovery、框架(Framework)、软件(APP),以备茶余饭后手贱刷机之用。

相关链接

  • Github Repository: huihut/awesome-oneplus-3t
  • 之前的相关博文:一加3T的刷机流程及玩机一些事
阅读全文 »

Flutter beta 版尝鲜(在 Windows + Android Studio 与 MacOS + VS Code 的安装配置)

发表于 2018-03-13 | 分类于 CS

Flutter 是一个 Google 发布的跨平台移动 UI 框架,使用 Dart 语言开发,可以构建高质量原生 iOS 、Android 以及 Fuchsia OS 应用,并且在排版、图标、滚动、点击等方面实现零差异。

Flutter 官网

鉴于最近出了 beta 版,就来尝鲜一下吧。

本文有 Windows + Android Studio 与 MacOS + VS Code 的体验。

阅读全文 »

GitHub 弃用 TLS 1.0、1.1 导致 push 异常 SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

发表于 2018-02-28 | 分类于 CS

报错

git push 到 Github 的时候出现异常:

1
2
fatal: unable to access 'https://github.com/huihut/interview.git/': error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
Pushing to https://github.com/huihut/interview.git
阅读全文 »

一个可以模仿你的表情的语音聊天机器人 —— Facemoji 废萌(OpenCV+Dlib+Live2D+图灵机器人+讯飞IAT语音听写+讯飞TTS语音合成)

发表于 2018-02-08 | 分类于 CS

概述

本文介绍一个可以模仿你的表情的语音聊天机器人 —— Facemoji 废萌

这是个 Unity 项目,其暂时有两个模块 :

  • 【模块一】是实时人脸卡通化(FaceTracking),使用 OpenCV 和 Dlib 检测面部表情,并实时转化为 Live2D 模型,然后可 录制 成 gif 图;
  • 【模块二】是人工智能(AI)使用 图灵机器人、讯飞IAT语音听写、讯飞TTS语音合成 进行语音聊天。
阅读全文 »

Qt的QVaiant中使用非QMetaType类型缺少Q_DECLARE_METATYPE宏定义错误

发表于 2017-12-05 | 分类于 CS

报错

1
2
3
E:\Qt\Qt5.9.3\5.9.3\mingw53_32\include\QtCore\qglobal.h:738: error: static assertion failed: Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system
#define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
^
阅读全文 »

OpenCV使用CMake和MinGW的编译安装及其在Qt配置运行

发表于 2017-12-03 | 分类于 CS

前言

本篇博文是使用 32 位的 MinGW 在 Windows 下编译 OpenCV 生成 32 位的 dll。

关于使用 64 位的 MinGW 编译 OpenCV 生成 64 位的 dll,见:OpenCV使用CMake和MinGW-w64的编译安装

编译好的 OpenCV(MinGW 版):

Github . huihut/OpenCV-MinGW-Build

阅读全文 »
<1234…6>

54 日志
1 分类
24 标签
RSS
GitHub CSDN 知乎 E-mail
© 2016 - 2024 huihut
由 Hexo 强力驱动
主题 - NexT.Muse