小编lin*_*llo的帖子

CMake CPack debian包

有人使用CPack脚本的工作示例来处理具有Qt和OpenGL依赖关系的debian包吗?

我已经设置了这个

set (CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libgcc1 (>= 1:3.4.2-12), libQtOpenGL (>=4.6.0), libQtCore (>=4.6.0), libQtGui (>=4.6.0), libglut (>=3.0), libICE (>=6.0), libX11 (>=6.0), libXext (>=6.0), libXmu (>=6.0), libXi (>=6.0), libstdc++ (>=6.0), libm (>=6.0), libgcc_s (>=1.0), libc (>=6.0), libGLU, libGL (>=1.0), libpthread" )
Run Code Online (Sandbox Code Playgroud)

我用Google搜索,但从未找到一个有效的例子.我的主要问题是如何首先为libGLU设置依赖项,然后为libGL和以下库设置依赖项.

一旦我创建了deb,安装程序就会说

 **Error: Dependency is not satisfiable: libXXX**
Run Code Online (Sandbox Code Playgroud)

其中XXX是我之前列出的库(主要是Qt库)

目前我的cmake版本是2.8.2但是cpack_add_component命令不起作用

debian qt cmake cpack

6
推荐指数
2
解决办法
6450
查看次数

如何将QSlider连接到QDoubleSpinBox

我想将QSlider连接到QDoubleSpinBox,但是当代码编译得很好并且运行简单的QSpinBox时,它对QDoubleSpinBox不起作用

QSlider *horizontalSlider1 = new QSlider();
QDoubleSpinBox *spinBox1 = new QDoubleSpinBox();

connect(spinBox1, SIGNAL(valueChanged(double)),horizontalSlider1,SLOT(setValue(double)) );
connect(horizontalSlider1,SIGNAL(valueChanged(double)),spinBox1,SLOT(setValue(double)) );
Run Code Online (Sandbox Code Playgroud)

qt connect signals-slots qslider

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

在没有循环的情况下从C++中的int中提取n个最重要的非零位

我想从C++中的整数中提取n个最高有效位,并将这n位转换为整数.

例如

int a=1200;
// its binary representation within 32 bit word-size is
// 00000000000000000000010010110000
Run Code Online (Sandbox Code Playgroud)

现在我想从该表示中提取4个最高有效数字,即1111

00000000000000000000010010110000
                     ^^^^
Run Code Online (Sandbox Code Playgroud)

并将它们再次转换为整数(十进制1001 = 9).

如何在没有循环的情况下使用简单的c ++函数?

c++ binary significant-digits bit

5
推荐指数
1
解决办法
4125
查看次数

如何查找图表是否为树及其中心

是否有一个算法(或一系列算法)可以找到,给定一个通用图结构G=(V,E),没有父节点,叶节点和子节点的概念,但只有neighboordhood关系:

1)如果G它是一棵树(检查|V| = |E|+1是否足够?)

2)如果图形实际上是树,叶子和它的中心?(即最小化树深度的图的节点)

谢谢

algorithm tree graph parent-child

5
推荐指数
1
解决办法
1802
查看次数

使用 Wavefront Obj 了解法线索引

我编写了一个无法正常工作的 C++ Obj 文件加载器。问题是在解析一个简单的 obj 文件时,如下所示:

# Blender v2.62 (sub 0) OBJ File: ''
# www.blender.org
mtllib cube.mtl
o Cube
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn -1.000000 -0.000000 -0.000000
vn -0.000000 -0.000000 1.000000
vn 1.000000 -0.000000 0.000000
vn 1.000000 0.000000 0.000001
vn -0.000000 1.000000 0.000000
vn 0.000000 -1.000000 0.000000 …
Run Code Online (Sandbox Code Playgroud)

c++ opengl wavefront normals vertex-array

5
推荐指数
1
解决办法
5029
查看次数

Scala 中有 -?- (减号)运算符吗?

我在图形的 Scala 实现中遇到过这个运算符(您可以在此处找到示例,其中插入了两个列表--和两个 Maps。

abstract class GraphBase[T, U] {
  case class Edge(n1: Node, n2: Node, value: U) {
    def toTuple = (n1.value, n2.value, value)
  }
  case class Node(value: T) {
    var adj: List[Edge] = Nil
    // neighbors are all nodes adjacent to this node.
    def neighbors: List[Node] = adj.map(edgeTarget(_, this).get)
  }

  var nodes: Map[T, Node] = Map()
  var edges: List[Edge] = Nil

  // If the edge E connects N to another node, returns the other node, …
Run Code Online (Sandbox Code Playgroud)

functional-programming scala list operator-overloading operators

5
推荐指数
1
解决办法
344
查看次数

boost :: lexical_cast和非内置类型的字符串化

关于具有复合类型的boost :: lexical_cast,我有一个(也许)简单的问题(在我的例子中)std::vector.

我的第一个模板化字符串化函数版本如下

template <typename T>
std::string stringiy(const T &t)
{
std::ostringstream o;
o<< t;
return o.str();
}
Run Code Online (Sandbox Code Playgroud)

一个工作的例子如下:

vector<int> x(10,-3;
cout << stringify<vector<int> >(x) << endl;
Run Code Online (Sandbox Code Playgroud)

输出, "-3-3-3-3-3-3-3-3"~ 但出于性能原因,我想利用boost::lexical_cast

现在我改变了函数实现:

template <typename T>
std::string stringiy(const T &t)
{
   return boost::lexical_cast<string>(t);
}
Run Code Online (Sandbox Code Playgroud)

虽然此方法适用于内置类型,但它会在上次使用时停止工作 std::vector

如果为向量创建专用模板,问题仍然存在(它不会编译)

template <typename T>
std::string stringiy(const std::vector<T> &t)
{
     vector<string> strret = num2str(t);
     string r;
     for ( vector<string>::iterator iter = strret.begin(); iter!=strret.end(); ++iter )
    r.append(*iter);
     return r;
}
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

g ++ - …

c++ templates boost lexical-cast stringify

4
推荐指数
1
解决办法
1984
查看次数

如何在OpenGL中使用圆圈剪辑

我想知道是否可以模拟在OpenGL中查看锁孔的效果.

我绘制了我的3D场景,但除了中心圆外,我想让每一个都变黑.

我试过这个解决方案,但它与我想要的完全相反:

// here i draw my 3D scene 

// Begin 2D orthographic mode
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

GLint viewport [4];
glGetIntegerv(GL_VIEWPORT, viewport);

gluOrtho2D(0, viewport[2], viewport[3], 0);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

// Here I draw a circle in the center of the screen
float radius=50;
glBegin(GL_TRIANGLE_FAN);
glVertex2f(x, y);
for( int n = 0; n <= 100; ++n )
{
    float const t = 2*M_PI*(float)n/(float)100;
    glVertex2f(x + sin(t)*r, y + cos(t)*r);
}
glEnd();

// end orthographic 2D mode
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix(); …
Run Code Online (Sandbox Code Playgroud)

opengl geometry buffer clipping

4
推荐指数
1
解决办法
3916
查看次数

返回Boost Graph中连接的组件子图的列表

我在使用原始图中的相同组件过滤子图时遇到问题.我想在子图的向量中输出它们.按照`connected_components中的例子,我试图让它适应我的需要:

// Create a typedef for the Graph type
typedef adjacency_list<
vecS,
vecS,
undirectedS,
property<vertex_index_t,int >,
property<edge_index_t,int> > Graph;

//typedef subgraph < Graph > SubGraph;
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::edge_descriptor Edge;
typedef graph_traits<Graph> GraphTraits;

// Iterators
typedef graph_traits<Graph>::vertex_iterator vertex_iter;
typedef graph_traits<Graph>::edge_iterator edge_iter;
typedef property_map<Graph, vertex_index_t>::type VertexIndexMap;
typedef property_map<Graph, edge_index_t>::type EdgeIndexMap;

std::vector<Graph> connected_components_subgraphs(const Graph &g)
{
    std::vector<int> component(num_vertices(g));
    int num = boost::connected_components(g, &component[0]);
    for (int i=0; i<component.size(); i++)
        cout << component[i] << endl;
    cout << "NUM=" << num << …
Run Code Online (Sandbox Code Playgroud)

c++ templates boost graph boost-graph

4
推荐指数
1
解决办法
2509
查看次数

OpenCV cv2.moments 将所有矩归零

由于某种我无法理解的原因, open cv 函数cv2.moments返回一个字典,其中我提供的轮廓的值全部为零。这是一个 MWE:

contour = [[[271, 67]],
           [[274, 67]],
           [[275, 68]],
           [[278, 68]],
           [[279, 69]],
           [[283, 69]],
           [[284, 70]],
           [[287, 70]],
           [[288, 71]],
           [[291, 71]],
           [[292, 72]],
           [[295, 72]],
           [[292, 72]],
           [[291, 71]],
           [[288, 71]],
           [[287, 70]],
           [[284, 70]],
           [[283, 69]],
           [[279, 69]],
           [[278, 68]],
           [[275, 68]],
           [[274, 67]]]

contour = np.asarray(contour)
moments = cv2.moments(contour)
Run Code Online (Sandbox Code Playgroud)

结果:

print(moments)

{'m00': 0.0, 'm10': 0.0, 'm01': 0.0, 'm20': 0.0, 'm11': 0.0, 'm02': 0.0, 'm30': 0.0, 'm21': 0.0, 'm12': 0.0, 'm03': …
Run Code Online (Sandbox Code Playgroud)

python geometry opencv image-processing computer-vision

4
推荐指数
1
解决办法
2877
查看次数