C++
lisarer
这个作者很懒,什么都没留下…
展开
-
C++11多线程系列第一部分
多线程编程对于大型的程序,复杂的算法应用十分广泛,最近一直在windows下开发,但是程序又需要在Linux等系统下跑,配置Boost标准库也是一个解决方案,C++11标准库实行时间比较久,现今大部分编译器都支持,所以用C++11实现多线程操作无疑是最好的选择!原创 2016-07-12 11:34:40 · 378 阅读 · 0 评论 -
C++封装调用SO简单示例
首先看下文件结构需要封装的是a.h,a.cpp里面有一个类g++ -fPIC -shared a.cpp -o liba.so原创 2017-08-18 17:09:15 · 4164 阅读 · 0 评论 -
c++读取写入文件--IO操作合集
写入文件// writing on a text file#include #include using namespace std;int main () { ofstream myfile ("example.txt"); if (myfile.is_open()) { myfile << "This is a line.\n"; myfile <<原创 2017-09-08 17:19:06 · 379 阅读 · 0 评论 -
OPENCV imencode与imdecode用法
上代码直接跑:#include#include#includeusing namespace std;using namespace cv;//this program is used for testing opencv encode and decode for jgeg picturesint main(){ Mat tstMat=imread("/home/l原创 2017-12-13 14:49:05 · 18951 阅读 · 1 评论 -
OPENCV 通过Mat访问每个像素
先上代码:#include#include#includeusing namespace std;using namespace cv;int main(){ Mat diff=imread("/home/lisa/dataset/02m16001200/0.jpg"); for(int i=0;i<diff.rows;i++) {原创 2017-12-14 15:05:42 · 288 阅读 · 0 评论 -
ubuntu通过命令直接安装QT
打开终端,输入:sudo apt-get install qt5-default qtcreator在安装之前最好先输入 sudo apt-get update启动QT:命令行输入:qtcreator原创 2018-01-23 10:14:27 · 14957 阅读 · 4 评论 -
Dlib 交叉编译错误汇总
首先 git clone --recursive https://github.com/tzutalin/dlib-android.git然后 cd dlib-android./envsetup下载的opencv地址不正确,自己去官网下载opencv-android-sdk,放在thirdparty文件夹下替换掉下载不完全的opencv重新运行./envsetup修改jni文件夹下所有调用open...原创 2018-03-08 13:55:55 · 1177 阅读 · 0 评论 -
卷积运算的常用操作
求padding:void test_pad(int *input,int width,int height,int *&output, int pad ){ //single channel int out_width=width+2*pad; int out_height=height+2*pad; if(!output) output=new int[25]; ...原创 2018-04-08 14:19:36 · 1222 阅读 · 0 评论 -
difference between unique_ptr and shared_ptr
smart pointers include unique_ptr and shared_ptr help to arrange memory allocations.the main difference between them are listed in the following code:can't use = operator but use std::move(sp13) 必须转移...原创 2018-04-09 20:04:59 · 203 阅读 · 0 评论 -
OPENCV CV_64FC1含义
很好理解:CV_64FC1 64F代表每一个像素点元素占64位浮点数,通道数为1CV_64FC3 64F代表每一个像素点元素占64点×3个浮点数,通道数为4原创 2018-05-23 10:09:53 · 22497 阅读 · 5 评论 -
单例模式示例
class Singleton{private: Singleton() { }; ~Singleton() { }; Singleton(const Singleton&); Singleton& operator=(const Singleton&);public: static Singleton& getInst...原创 2018-06-23 16:21:39 · 248 阅读 · 0 评论 -
Android Studio新建工程出错
简单的解决方案:gradual.build中把:25+改成23+,target sdk与compile SDK全部区分开来。原创 2017-02-06 09:51:19 · 673 阅读 · 0 评论 -
C++构造与析构类与类中的指针对象
类的构造与析构是一个较复杂的问题,尤其涉及到一个类中包含多个对象时,比较难以理解,先看代码:#define _CRTDBG_MAP_ALLOC#include #include #includeusing namespace std;class inner{public: inner(){}; ~inner(){ cout << "inner destruc原创 2016-07-12 16:51:15 · 838 阅读 · 0 评论 -
父类与子类析构与函数调用关系
一段简单的代码,说明了为什么析构函数要用虚函数、以及父类与子类的函数调用关系原创 2016-07-13 16:59:34 · 541 阅读 · 0 评论 -
c++调用动态链接库DLL
先占坑,这周写!原创 2016-07-27 15:37:33 · 795 阅读 · 1 评论 -
c++11 批量产生多个线程
先占坑,以后写原创 2016-07-19 09:34:58 · 3400 阅读 · 0 评论 -
c++多个线程操作与互斥
典型的c++的卖票程序,看代码即可明白:#include#include#includeusing namespace std;static int ticket = 100;mutex mytmx;void sellticket(){ while (ticket >= 0) { if (mytmx.try_lock()) { cout <原创 2016-07-19 16:50:44 · 459 阅读 · 0 评论 -
c++11多线程之主线程与子线程数据传输与共享
c++线程间的数据传输与共享分很多种,而使用全局变量是很常见的一种,下面先来看看最基础的使用全局变量进行数据共享的例子:#include#includeusing namespace std;static int id = 1;void autoincrease(){ id=id+1;}int main(){ cout << "before increase " << id原创 2016-07-20 10:16:36 · 9329 阅读 · 1 评论 -
函数指针的简单代码示例
函数指针在c++使用回调函数时必学项目,不使用函数指针时的代码:// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#includeusing namespace std;float Pluscode(float a, float b){ return a + b; }float min原创 2016-08-01 15:27:51 · 466 阅读 · 0 评论 -
c++如何调用lib文件 静态库文件
先占坑!原创 2016-07-27 15:58:53 · 2266 阅读 · 0 评论 -
GLOG使用举例
先占坑,回头慢慢写!原创 2016-08-23 11:47:50 · 290 阅读 · 0 评论 -
截止总结前新学到的还需要巩固的知识
人们都说,进入一家新公司,学起东西来总是最快的,而学东西,很重要的一点,就是能熟练使用各种工具,总结一下最近用过的工具:1、google protobuf非常好用的结构化数据传输方式,已有文章阐明使用方法;2、gtestgoogle单元测试方式,暂时还感受不到强大的地方,主要是使用的场景较为简单;3、QTQT也算是一个大头了,原创 2016-10-29 14:56:32 · 481 阅读 · 0 评论 -
JAVA JNI技术简单举例
JAVA JNI是与操作系统本地代码相互调用的功能的接口,从例子上手JAVA JNI,从这个例子就能看明白JNI技术的功用:1.java中声明native方法:package com.lisapublic class testnative{public native void sayHello();public static void main(String []a原创 2016-11-01 11:00:27 · 394 阅读 · 0 评论 -
linux opencv调用手机摄像头
手机端安装IP摄像头先上源码:#include "cv.h"#include "highgui.h"#include int main(int, char**) { cv::VideoCapture vcap; cv::Mat image;CvCapture *capture ; const std::string videoStreamAddr原创 2017-02-05 11:08:29 · 3824 阅读 · 3 评论