c++
Lafer碎碎
这个作者很懒,什么都没留下…
展开
-
利用 opencv 对图像进行背景颜色替换(空洞填充) 完成背景颜色修改
#include <opencv2/opencv.hpp>#include <iostream>#include <opencv2/highgui/highgui_c.h>using namespace cv;using namespace std;void fillHole(const Mat srcBw, Mat &dstBw);Mat mat_to_samples(Mat &image);int main(int argc, char原创 2020-07-20 20:40:19 · 1994 阅读 · 0 评论 -
利用python 批量读取文件夹下文件(特定格式) 以txt为例,并将其数据拼接
import os# tasksdirpath = "new_pic.txt"# pycmd = "test_Titans.exe"deeplrlt = "\\image\\001_"def main(): listdir = os.listdir(deeplrlt) for i in range(0, len(listdir)): if not listdir[i].startswith("20"): co原创 2020-07-20 20:03:55 · 826 阅读 · 0 评论 -
读取 txt/其他格式数据,(以opencv 指针显示数据格式或 Mat数据格式)转为图片显示
cv::Mat image1; image1.create(Width, eHeight, CV_8U); ifs.open(path, std::ios::binary); if (!ifs.is_open()) { std::cout << "Cannot open file " <<path << std::endl; return image1; } ifs.rea...原创 2020-07-11 11:30:48 · 270 阅读 · 0 评论 -
qstring 转为 string 且不会导致中文乱码方法
std::stringFileNames = std::string((const char *)fileName.toLocal8Bit());原创 2020-07-11 09:19:54 · 169 阅读 · 0 评论 -
获取文件种类(png?jpg)
fs::path p(path); std::string pattern = p.extension().string();如 path=c:\image\1.png“”;pattern = “.png”原创 2020-07-11 09:19:08 · 175 阅读 · 0 评论 -
循环队列设计时,队列下标防止越界的操作
rear=(rear+1)%capacity;队列长度最大为maxsize,每做一次入队操作指针向上移动,当超过最大长度时,回归到最初capacity是你的数组的大小,bai如果最后一du个元素位置被使用后,要再存下一个元素,那zhi么按循环队列的定义,应该dao是存到数组的开头,而对capacity取余则可以使得下标从capacity-1变为0,然后递增,达到循环的目的...原创 2020-07-09 20:23:35 · 545 阅读 · 0 评论 -
读取特定文件夹路径,并读取所有图片放入数组(c++ opencv)
for (auto &p : fs::directory_iterator(path)) { if (fs::is_directory(p) && p.path().filename() == "images") { std::vector<cv::String> images; // notice here that we are using the Opencv's embedded "String" class cv::Strin..原创 2020-07-09 10:06:40 · 600 阅读 · 0 评论 -
C++11 获取路径下的文件路径,判断是否存在某个文件夹。。用于后续访问(特定名称)
for (auto &p : fs::directory_iterator(image_dir)) { if (fs::is_directory(p) && p.path().filename() == "images") { cv::FileStorage fs(p.path().string() + "\\cimage1.txt", cv::FileStorage::READ); } }判断是否存在某个文件 if (std::expe原创 2020-07-07 16:04:27 · 1273 阅读 · 0 评论 -
读取(视差图)数据,以二进制读取文件内的数据,并以一定的长度进行分割
std::ifstream ifs; ifs.open(FileNames, std::ios::binary); int buffer_size = imageWidth * imageHeight * 2; unsigned short *buffer = new unsigned short[imageWidth * imageHeight]; ifs.read((char *)buffer, buffer_size);ifs.read((char *)buffer, bu..原创 2020-07-07 15:37:05 · 221 阅读 · 0 评论 -
大型程序源码编译时(插件调试)cloudCompare
此时,即可开始debug】原创 2020-07-07 14:26:25 · 201 阅读 · 0 评论 -
寻找字符串 (如地址中某一文件夹的位置)截取字符串想要的字符
int found = FileNames.find("images"); std::string Camera = FileNames; Camera.erase(found, Camera.size() - found); //截取出images 文件夹前的路径 //原路径 C:\Users\Andy\Desktop\dfgdfg\images //现在路径 C:\Users\Andy\Desktop\dfgdfg\...原创 2020-07-07 13:57:10 · 228 阅读 · 0 评论 -
按行读取文件内容
std::ifstream txtfile;//打开读取的文件 std::string temp; std::string file_path = R"(D:\\chengxu\\py\\new_file.yml)"; txtfile.open(file_path, std::ios::in); while (!txtfile.eof()) // 若未到文件结束一直循环 { getline(txtfile, temp);//一行一行读取 b...原创 2020-06-28 13:34:32 · 316 阅读 · 0 评论 -
批量读取文件夹中文件路径
#include <filesystem>namespace fs = std::experimental::filesystem;int main(){ for (auto &p : fs::directory_iterator(dir)) { if (fs::is_directory(p) && p.path().filename() == "image") { float mm2m = 1000.f; .原创 2020-06-28 13:01:22 · 445 阅读 · 0 评论 -
动态创建 二维数组和三维数组,最后将数据转为OPENCV图片显示
二维 //int **dpPT1 = new int*[Index_Qty];//动态申请二维数组 //int **dpPT2 = new int*[Index_Qty]; //int **dpPP = new int*[Index_Qty]; //int **dpPVL = new int*[Index_Qty]; //int **dpPVR = new int*[Index_Qty]; //for (int i = 0; i < Index_Qty; ++i) { // dpPT原创 2020-05-22 11:30:50 · 493 阅读 · 0 评论 -
转载——亲测可用!对vector容器中的数据进行滤波!
/***************************************** Copyright (c) 2015 Jingshuang Hu @filename:demo.cpp @datetime:2015.12.09 @author:HJS @e-mail:jingshuang_hu@163.com @blog:http://blog.csdn.net/hujingshuang *****************************************/ #inc转载 2020-05-15 11:50:25 · 460 阅读 · 0 评论 -
C++读取TXT 文件内的数据点,并放入vector,用于读写
std::vector<int> list1; std::ifstream infile;//定义读取文件流,相对于程序来说是in infile.open("sample_value.txt");//打开文件 if (!infile.is_open())//判断文件是否打开 { std::cout << "Error opening file" << std::endl; } int count_Qty = dataAScan->GetSample.原创 2020-05-13 16:06:19 · 2387 阅读 · 0 评论 -
Mfc 保存界面上显示的图片,亲测可用~~!!添加保存成功按钮!
// TODO: 在此添加控件通知处理程序代码 //CWnd* bmpShow = GetDlgItem(IDC_PICTURE_DATA1_BOUNDS3); CWnd* bmpShow = GetDlgItem(IDC_PICTURE_DATA1_BOUNDS3); CDC *pdc = bmpShow->GetDC(); //CImage imag; ATL::CImage imag; //标识符以防不明确 CRect rect; GetClientRect(&re原创 2020-05-13 15:09:38 · 528 阅读 · 3 评论 -
创建动态二维数组,并存数据到txt中,按矩阵的形势存储,并将数据转为图片
std::ofstream outputfile, picture; outputfile.open("wave_data2.txt"); int **dp2 = new int*[Index_Qty];//动态申请二维数组nxm for (int i = 0; i <rows; ++i) { dp2[i] = new int[cols]; } //读取不同row,col位置的最大sample_index值 for (long roi_in = 0; roi_index <原创 2020-05-12 08:11:48 · 280 阅读 · 0 评论 -
二维数组初始化
// TestProgramme.cpp : 定义控制台应用程序的入口点。//#include “stdafx.h”#include using namespace std;class A{public:static int arry[15][15];};int A::arry[15][15];//int A::arry[15][15]={-1};int _tmain(int argc, _TCHAR* argv[]){for(int i=0;i<15;i++)for(i原创 2020-05-09 22:58:13 · 216 阅读 · 0 评论 -
简单循环读取文件夹中的图片用于opencv处理
std::stringstream StrStm;//用以 重载了<>i 的函数//string StrStm;string imageFileName;string filePath = “leo”;StrStm << i ;StrStm >> imageFileName;filePath += imageFileName;filePath +...原创 2020-05-05 16:16:51 · 760 阅读 · 0 评论 -
yolov3,利用windows编译,使用opencv显示,后期可转移至QT中制作
参考https://blog.csdn.net/Augurlee/article/details/103530487https://blog.csdn.net/stjuliet/article/details/87884976?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_rel...原创 2020-04-30 17:41:39 · 312 阅读 · 0 评论 -
解决python调用TensorFlow时出现FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecate
最近因为要做一个基于深度学习的人脸识别项目,要用到TensorFlow,但是下载完成后后发现import tensorflow总是出现FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood a...转载 2020-04-20 10:40:45 · 289 阅读 · 0 评论 -
人脸识别的应用,转载他人博客,tensorflow+opencv
1.传统的利用opencv分类器直接进行人脸识别,以此保存人脸数据图片,用于后期存储 import cv2import sys from PIL import Image def CatchPICFromVideo(window_name, camera_idx, catch_pic_num, path_name): cv2.namedWindow(window_na...转载 2020-04-19 11:21:20 · 307 阅读 · 0 评论 -
QT 中文乱码 如何修改
QMessageBox::information(this,“qwe”, “开心”);更改为QMessageBox::information(this,“qwe”, QString::fromLocal8Bit(“开心”));原创 2020-03-31 20:27:55 · 168 阅读 · 0 评论 -
中值滤波器 C++ 实现
均值滤波是像素周围的33的像素做平均值操作, 那么中值就是在33中的像素中寻找中值一般来说这个中值滤波是去除椒盐噪声的非常理想的选择。/**** method to remove noise from the corrupted image by median value* @param corrupted input grayscale binary array with corrup...转载 2020-03-23 19:00:57 · 655 阅读 · 0 评论 -
均值滤波 通过C++ 实现
具体说说均值滤波器是什么东西吧。其实这个东西就是在图像处理的时候, “把每个像素都用周围的8个像素来做均值操作 ”主要还是平滑图像的用处, 有的图像的锐度很高,用这样的均值算法,可以把锐度降低。使得图像看上去更加自然,下面就有几幅图我们可以看出一些端倪:/**** method to remove noise from the corrupted image by mean value...转载 2020-03-23 18:51:43 · 918 阅读 · 1 评论 -
常用图像处理算法 c++使用 成形
/*函数名称:MakegGray()*/ /*函数类型:void*/ /*功能:真彩色转化成256色灰度图像。*/ /*****************...转载 2020-03-23 14:45:04 · 153 阅读 · 0 评论 -
++i 与 i++
#include <iostream>using std::cout; using std::endl;int main() { int i = 0, j; j = ++i; // j = 1, i = 1: prefix yields the incremented value cout << i << " " << j <&...原创 2019-11-18 09:05:04 · 92 阅读 · 0 评论 -
sizeof
#include <iostream>using std::cout; using std::endl;#include <cstddef>using std::size_t;int ia[] = {0,1,2,3,4,5,6,7,8,9};int main(){#ifdef CONSTEXPR_VARS // sizeof(ia)/sizeof...原创 2019-11-18 09:00:11 · 105 阅读 · 0 评论 -
c++ ifstream用法 (转载)
ofstream是从内存到硬盘,ifstream是从硬盘到内存,其实所谓的流缓冲就是内存空间 在C++中,有一个stream这个类,所有的I/O都以这个“流”类为基础的,包括我们要认识的文件I/O. stream这个类有两个重要的运算符: 1、插入器(<<) 向流输出数据。比如说系统有一个默认的标准输出流(cout),一般情况下就是指的显...转载 2019-11-17 21:48:09 · 10658 阅读 · 0 评论 -
string 的使用方法 strcpy strcmp strlen
#include <string>using std::string;#include <iostream>using std::cout; using std::endl;#include <cstring>#include <cstddef>using std::size_t;int main() { string s1...原创 2019-11-17 13:18:09 · 347 阅读 · 0 评论 -
判断 大小写.标点符号、空格与否c++
#include <string>using std::string;#include <cctype>using std::isupper; using std::toupper;using std::islower; using std::tolower;using std::isalpha; using std::isspace;#include &...原创 2019-11-17 13:05:16 · 382 阅读 · 0 评论 -
数组,对考试分数分级输出
#include <cstddef>using std::size_t;#include <vector>using std::vector;#include <iostream>using std::cin; using std::cout; using std::endl;int main (){ vector<unsigne...原创 2019-11-17 12:46:19 · 315 阅读 · 0 评论 -
c语言中unsigned中-5
会溢出,所以等于2的32次方减5。相当于向下溢出就要“向高位借位”,unsigned有32个二进制位,所以每次溢出就加2的32次方。原创 2019-11-16 14:59:04 · 588 阅读 · 0 评论 -
decltype用法
//(1) 基本用法int getSize();int main(void){ int tempA = 2; /*1.dclTempA为int.*/ decltype(tempA) dclTempA; /*2.dclTempB为int,对于getSize根本没有定义,但是程序依旧正常,因为decltype只做分析,并不调用getSize()....原创 2019-11-16 14:24:51 · 302 阅读 · 0 评论 -
利用scanf_s写一个简答的计算器 c++、c 练手小程序
sacnf_s 是一个读取键盘输入值,用以保存的函数scanf_s("%d,%d,%d",&a,&b,&c);通过取地址,将键盘所敲的 键位 以具体的格式进行 取用但是,为了防止泄露,如果键入字符(数组)的话,需要在后面加上 容量的限制scanf_s("%d,%c,%d",&a,&b,6,&c);最后他通过 ENTER 建结束...原创 2019-11-15 22:25:43 · 237 阅读 · 0 评论 -
指针 取地址
#include <iostream>int main(){ // i is an int; p is a pointer to int; r is a reference to int int i = 1024, *p = &i, &r = i; // three ways to print the value of i std::cout <...原创 2019-11-16 12:12:16 · 1128 阅读 · 0 评论 -
无符号int、有符号int、无符号char、有符号char范围
计算机以二进制补码存储数值,当一个具有符号位的数据值储存在计算机中的时候,计算机会以最高位为符号位,其余位数取该数绝对值的二进制补码来储存。有符号char范围:有符号char最大值(正数):0111 1111即127,最小值1000 0000(补码) 即-128。注1000 0000 -1=0111 1111 即2^7-1=128-1=127;-128即- 2^7;所以有符号char 取...转载 2019-11-16 14:00:19 · 2200 阅读 · 0 评论 -
指针传递
#include <iostream>using std::cout;using std::endl;int main(){ int ival = 1024; int *pi = &ival; // pi points to an int int **ppi = π // ppi points to a pointer ...原创 2019-11-16 14:13:33 · 153 阅读 · 0 评论