小编nki*_*int的帖子

使用gulp选择并移动目录及其文件

我目前正在使用gulp来调用bash脚本来清理我的dist/目录并将相应的文件移动到clean目录.我希望这可以用gulp完成,因为我不确定该脚本是否可以在非*nix文件系统上运行.
到目前为止,我正在使用gulp-clean模块来清理dist/目录,但是当我尝试将所需目录及其文件移动到dist文件夹时,目录为空.

var gulp = require('gulp'),
    clean = require('gulp-clean');

gulp.task('clean', function(){
  return gulp.src(['dist/*'], {read:false})
  .pipe(clean());
});

gulp.task('move',['clean'], function(){
  gulp.src(['_locales', 'icons', 'src/page_action', 'manifest.json'])
  .pipe(gulp.dest('dist'));
});

gulp.task('dist', ['move']);
Run Code Online (Sandbox Code Playgroud)

调用带有正确目录gulp distdist/目录中的结果,但它们都是空的

$ ls dist/*
dist/manifest.json

dist/_locales:

dist/icons:

dist/page_action:
Run Code Online (Sandbox Code Playgroud)

如何将目录及其内容复制到该dist/文件夹?

glob node.js gulp

96
推荐指数
2
解决办法
7万
查看次数

如何在LESS中使用if语句

我正在寻找某种if语句来控制background-color不同的div元素.

我已经尝试了下面的内容,但它没有编译

@debug: true;

header {
  background-color: (yellow) when (@debug = true);
  #title {
      background-color: (orange) when (@debug = true);
  }
}

article {
  background-color: (red) when (@debug = true);
}
Run Code Online (Sandbox Code Playgroud)

css if-statement less

55
推荐指数
4
解决办法
9万
查看次数

来自cv :: solvePnP的世界坐标中的摄像机位置

我有一个校准过的相机(内在矩阵和失真系数),我想知道相机位置知道一些3d点及其在图像中的对应点(2d点).

我知道,cv::solvePnP能帮助我,看完这个这个我明白solvePnP的,我的产出rvectvec是对象在相机的旋转和平移坐标系.

所以我需要找出世界坐标系中的摄像机旋转/平移.

从上面的链接看来,代码在python中是直截了当的:

found,rvec,tvec = cv2.solvePnP(object_3d_points, object_2d_points, camera_matrix, dist_coefs)
rotM = cv2.Rodrigues(rvec)[0]
cameraPosition = -np.matrix(rotM).T * np.matrix(tvec)
Run Code Online (Sandbox Code Playgroud)

我不知道python/numpy东西(我正在使用C++),但这对我来说没有多大意义:

  • rvec,来自solvePnP的tvec输出是3x1矩阵,3个元素向量
  • cv2.Rodrigues(rvec)是一个3x3矩阵
  • cv2.Rodrigues(rvec)[0]是3x1矩阵,3个元素向量
  • cameraPosition是一个3x1*1x3矩阵乘法,是一个.. 3x3矩阵.我如何在opengl中使用这个简单glTranslatefglRotate调用?

c++ opengl opencv computer-vision pose-estimation

51
推荐指数
2
解决办法
4万
查看次数

崇高文本中的ctags

我只是在ubuntu 10.10下使用Exuberant Ctags 5.8 下载了sublime text 2 beta 2182

我想用它来进行c ++编码,我需要一些自动编译和代码导航.(我习惯用cdt遮蔽)

我用Google搜索,我发现CTAGS一个很酷的工具,可以做到这一点,并没有对崇高的文本插件支持在这里.

问题是我想要创建标记文件:

  1. c ++标准lib(std::vector std::map etc)

  2. 我正在使用的所有框架类.

点1(我认为)与第2点相同,我只需要创建一个std lib的标签列表 /usr/include/c++/4.4.5/

所以我下载了插件并安装了它,我用这种方式制作了一个标签列表:

$ cd /absolute_path_of_my_cpp_framework/
$ ctags -R *
Run Code Online (Sandbox Code Playgroud)

我修改/home/me/.config/sublime-text-2/Packages/CTagss/CTags.sublime-settings了这一行:

"extra_tag_files" : [".gemtags", "/absolute_path_of_my_cpp_framework/tags"]
Run Code Online (Sandbox Code Playgroud)

现在我打开一个cpp文件,将光标指向我的框架的类名,并使用键绑定ctrl+t ctrl+t,没有任何反应.只有底部栏中的此消息:

找不到"class_name"

有人能帮我吗?

c++ ctags sublimetext sublimetext2

30
推荐指数
1
解决办法
1万
查看次数

将qtcreator与makefile项目一起使用

我有一个makefile项目.我知道在Eclipse CDT中可以加载makefile项目.

是否可以在qtcreator中加载它?

makefile qt-creator

29
推荐指数
2
解决办法
5万
查看次数

std :: vector to string with custom delimiter

我想用自定义分隔符将a的内容复制vector到一个long string.到目前为止,我已经尝试过:

// .h
string getLabeledPointsString(const string delimiter=",");
// .cpp
string Gesture::getLabeledPointsString(const string delimiter) {
    vector<int> x = getLabeledPoints();
    stringstream  s;
    copy(x.begin(),x.end(), ostream_iterator<int>(s,delimiter));
    return s.str();
}
Run Code Online (Sandbox Code Playgroud)

但我明白了

no matching function for call to ‘std::ostream_iterator<int, char, std::char_traits<char> >::ostream_iterator(std::stringstream&, const std::string&)’
Run Code Online (Sandbox Code Playgroud)

我试过charT*但我得到了

error iso c++ forbids declaration of charT with no type
Run Code Online (Sandbox Code Playgroud)

然后我尝试使用char,ostream_iterator<int>(s,&delimiter) 但我在字符串中得到奇怪的字符.

任何人都可以帮助我理解编译器在这里期待什么吗?

c++ string vector

27
推荐指数
6
解决办法
3万
查看次数

OpenCV的脉冲,高斯和盐和胡椒噪音

我正在着名的冈萨雷斯"数字图像处理"研究图像处理,并谈论图像恢复,很多例子都是用计算机生成的噪声(高斯,盐和胡椒等)完成的.在MATLAB中有一些内置函数可以做到这一点.那么OpenCV呢?

opencv image-processing

27
推荐指数
5
解决办法
4万
查看次数

在c ++中编译opencv

我有一个只导入的文件:

#include <iostream>
#include <stdio.h>

#include "cxcore.hpp"
#include "highgui.hpp"

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{

}
Run Code Online (Sandbox Code Playgroud)

我尝试用g ++编译-I/usr/include/opencv -lopencv -lm m.cpp

但得到whit错误:

在/usr/include/opencv/cxcore.hpp:46中包含的文件中,来自m.cpp:5:/usr/include/opencv/cxmisc.h:214:错误:在'void之前的预期构造函数,析构函数或类型转换'/usr/include/opencv/cxmisc.h:220:错误:'int'之前的构造函数,析构函数或类型转换/usr/include/opencv/cxmisc.h:226:错误:'CV_INLINE'没有命名为输入/usr/include/opencv/cxmisc.h:516:错误:'CV_DEPTH_MAX'未在此范围内声明/usr/include/opencv/cxmisc.h:522:错误:'CV_DEPTH_MAX'未在此范围内声明/ usr/include/opencv/cxmisc.h:522:错误:'CV_CN_MAX'未在此范围内声明在m.cpp中包含的文件中:5:/usr/include/opencv/cxcore.hpp:70:错误:模板声明'cv :: CV_EXPORTS cv :: Size_'/usr/include/opencv/cxcore.hpp:71:错误:'cv :: CV_EXPORTS cv :: Point_'/usr/include/opencv/cxcore.hpp的模板声明: 72:错误:'cv :: CV_EXPORTS cv :: Rect_'/usr/include/opencv/cxcore.hpp:77的模板声明:错误:在'之前的预期初始化程序' fromUtf16'/usr/include/opencv/cxcore.hpp:78:错误:在'toUtf16'之前预期的初始化程序'/usr/include/opencv/cxcore.hpp:80:错误:'format'/ usr/include/opencv之前的预期初始化程序/cxcore.hpp:82:错误:在':'之前的预期初始化程序令牌m.cpp:38:错误:在输入结束时预期'}'

这是我的copencv lib内容:

alberto@zefiro:~$ ls /usr/include/opencv/
cvaux.h    cvcompat.h  cv.hpp        cvtypes.h  cvvidsurv.hpp  cxcore.h    cxerror.h  cxmat.hpp  cxoperations.hpp  highgui.h    ml.h
cvaux.hpp  cv.h        cvinternal.h  cvver.h    cvwimage.h     cxcore.hpp  cxflann.h  cxmisc.h   cxtypes.h         highgui.hpp
Run Code Online (Sandbox Code Playgroud)

我在ubuntu 10.10上

c++ opencv compilation image-processing

21
推荐指数
3
解决办法
6万
查看次数

异步/等待超时

我使用的是Node.js和TypeScript,我正在使用它async/await.这是我的测试用例:

async function doSomethingInSeries() {
    const res1 = await callApi();
    const res2 = await persistInDB(res1);
    const res3 = await doHeavyComputation(res1);
    return 'simle';
}
Run Code Online (Sandbox Code Playgroud)

我想为整个功能设置超时.即如果res1需要2秒,res2需要0.5秒,res3需要5秒我想要超时,3秒后让我抛出错误.

正常setTimeout调用是一个问题,因为范围丢失:

async function doSomethingInSeries() {
    const timerId = setTimeout(function() {
        throw new Error('timeout');
    });

    const res1 = await callApi();
    const res2 = await persistInDB(res1);
    const res3 = await doHeavyComputation(res1);

    clearTimeout(timerId);

    return 'simle';
}
Run Code Online (Sandbox Code Playgroud)

我无法正常地抓住它Promise.catch:

doSomethingInSeries().catch(function(err) {
    // errors in res1, res2, res3 will be …
Run Code Online (Sandbox Code Playgroud)

timeout node.js promise async-await typescript

21
推荐指数
2
解决办法
2万
查看次数

快速实现pop_front到std :: vector的方法

我正在使用一些类和几个使用std :: vector的实用方法.

现在我需要在其中一个类上使用pop_front - push_back方法的每一帧(但它们都是链接的,并且一起工作所以我不能只更改一个).

大多数操作都是遍历所有元素和push_back操作,因此我应该做的最好的工作是:分叉这些类和实用程序的存储库,模板化所有内容并使用deque或list.

但这意味着大量的代码重写和大量的测试会让我错过截止日期.

所以我需要建议将高效的pop_front写入静态大小的向量(大小不会改变).

我在这里找到一种方式:

template<typename T>
void pop_front(std::vector<T>& vec)
{
   vec.front() = vec.back();
   vec.pop_back();
   vec.front() = vec.back();  // but should this work?
}
Run Code Online (Sandbox Code Playgroud)

另一个想法应该是:

template<typename T>
void pop_front(std::vector<T>& vec, already_allocated_vector vec1)
{
   vec1.clear();
   copy(vec.begin(), vec.end()-1, vec1.begin());
   copy(vec1.begin(), vec1.end(), vec.begin());
}
Run Code Online (Sandbox Code Playgroud)

这两种解决方案的速度有多快?还有其他方法吗?

c++ vector data-structures

20
推荐指数
2
解决办法
8万
查看次数