与此问题类似,我在OS X 10.10.3上使用OpenCV和CMake时遇到了麻烦.
经过一番麻烦,我终于设法在我的系统上构建了OpenCV 3.0 beta; 标题现在位于/usr/local/include和libs - 正如他们应该 - 所在/usr/local/lib.我有使用OpenCV的小程序,我CMakeLists.txt看起来像这样
set( CMAKE_CXX_FLAGS "-O3 -w" )
find_package( OpenCV REQUIRED )
if(OpenCV_FOUND)
message("Found OpenCV")
message("Includes: " ${OpenCV_INCLUDE_DIRS})
endif(OpenCV_FOUND)
add_executable( cannyDetector canny/canny.cpp )
target_link_libraries( cannyDetector ${OpenCV_LIBS} )
Run Code Online (Sandbox Code Playgroud)
我很平常
Undefined symbols for architecture x86_64:
"vtable for cv::_InputArray", referenced from:
_main in correctImage.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for cv::_OutputArray", referenced from:
_main in correctImage.o …Run Code Online (Sandbox Code Playgroud) 我正在尝试这样做:
import re
sentence = "How are you?"
print(re.split(r'\b', sentence))
Run Code Online (Sandbox Code Playgroud)
结果是
[u'How are you?']
Run Code Online (Sandbox Code Playgroud)
我想要类似的东西[u'How', u'are', u'you', u'?'].怎么能实现这一目标?
考虑一个非常简单的setup.py:
from setuptools import setup, find_packages
print('WAAAAAAAAA') # executed twice!
setup(
name="foo",
version="190425",
description="bar",
author="Developers",
author_email="me@domain.com",
install_requires=["pyzmq", "pybullet"],
packages=find_packages(),
)
Run Code Online (Sandbox Code Playgroud)
为什么模块在运行时加载两次pip install . -v?我可以做些什么来保护代码,以便它每次调用只运行一次pip,就像setup()?
我想运行git ls-file --modified以获取具有未暂存更改的文件列表。我惊讶地发现它可以在根目录中工作,但不能在任何子目录中工作,它只打印子目录中的文件(例如git status,与 相比)。
重现步骤:
mkdir repo
cd repo
git init
touch file.txt
git add file.txt
mkdir subdirectory
echo "foo" >> file.txt # file now has unstaged changes
git ls-files --modified # This prints 'file.txt'
cd subdirectory/
git ls-files --modified # This prints nothing
Run Code Online (Sandbox Code Playgroud)
我怎样才能改变 git 的行为呢?
我在OS X 10.10上尝试用GLUT和OpenGL构建一个C'项目'.我把它简化为一个展示我问题的最小例子.我有以下内容CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(GLUT REQUIRED)
if(OpenGL_FOUND) # never true, but printed as true
link_directories(${OpenGL_LIBRARY_DIRS})
include_directories(${OpenGL_INCLUDE_DIR})
endif(OpenGL_FOUND)
if(GLUT_FOUND)
link_directories(${GLUT_LIBRARY_DIR})
include_directories(${GLUT_INCLUDE_DIR})
endif(GLUT_FOUND)
# print all vars because wtf
get_cmake_property(_v VARIABLES)
foreach(_v ${_v})
message(STATUS "${_v}=${${_v}}")
endforeach()
add_executable(main main.c)
target_link_libraries(main ${GLUT_LIBRARY} ${OPENGL_LIBRARY})
Run Code Online (Sandbox Code Playgroud)
这main.c只是一个包含两个标题的假人:
#include <gl.h>
#include <glut.h>
int main()
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
现在,cmake .运行正常并且为了调试目的打印所有变量.我从某个地方拿了代码,我不太了解cmake知道它是否按照我的想法行事.无论如何,运行make返回
main.c:1:10: fatal error: 'gl.h' file not found
#include <gl.h>
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
标题gl.h实际上存在,/System/Library/Frameworks/OpenGL.framework/Headers …
我有一个问题,我想绘制数据分布,其中某些值经常出现,而其他值则非常罕见。总点数约为30.000。渲染像 png 或(上帝禁止)pdf 这样的图需要很长时间,而且 pdf 太大而无法显示。
所以我想对数据进行二次采样以绘制绘图。我想要实现的是删除很多重叠的点(密度高的点),但保留密度低的点,概率几乎为 1。
现在,numpy.random.choice允许指定一个概率向量,我根据数据直方图计算出该概率向量,并进行了一些调整。但我似乎无法得到我的选择,以便真正保留稀有点。
我附上了数据的图像;分布的右尾部的点少了几个数量级,所以我想保留这些点。数据是 3d 的,但密度仅来自一维,因此我可以将其用作给定位置中有多少个点的度量
我在脚本中使用readonly local如下变量定义函数:
test.sh
function test_function() {
readonly local foo="bar"
}
Run Code Online (Sandbox Code Playgroud)
在采购之前,foo当然是未定义的
$> echo $foo
$>
Run Code Online (Sandbox Code Playgroud)
但是当我获取并运行该函数时
$> source test.sh
$> test_function
$> echo $foo
bar
$>
Run Code Online (Sandbox Code Playgroud)
突然间,变量泄漏超出了其范围。删除readonly即可解决问题。我对 a 的使用有什么误解,readonly并且local两者都可以使用而不会出现此问题吗?
用例是,test_function多次调用时我收到错误/警告,因为该变量应该是只读的,但已经定义了。
我想用来#pragma clang diagnostic push忽略一些包含的头文件的警告。所以我写这个:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wall"
#include "SpinGenApi/SpinnakerGenApi.h"
#include "Spinnaker.h"
#pragma clang diagnostic pop
Run Code Online (Sandbox Code Playgroud)
但在使用此代码编译文件时,编译器仍然会打印警告。我需要更改什么才能忽略这些标头的所有警告?
我想在可能固定数量的布尔值上模板化一个类,对它们进行计数,然后使用该数字作为基类的模板参数。像这样的东西
\ntemplate <int Dimensionality> struct Foo {}; // I want to inherit from this\n\n// helpers to compile-time count the true values among bools\ntemplate <bool B, bool... Args>\nstruct count_true {\n static constexpr int value = count_true<B>::value + count_true<Args...>::value;\n};\n\ntemplate <>\nstruct count_true<true> {\n static constexpr int value = 1;\n};\ntemplate <>\nstruct count_true<false> {\n static constexpr int value = 0;\n};\n\n// I want something like this, pseudocode\ntemplate <bool... Args>\nstruct Bar : public Foo<count_true<Args...>::value> {\n Bar(bool... args) {\n // do something with the parameters\n static_assert(sizeof...(args) <= …Run Code Online (Sandbox Code Playgroud) 我们有一个CI脚本,可以对存储库中的所有Python文件进行样式检查,如下所示:
#!/usr/bin/env bash
find . -name \*.py -exec pep8 --ignore=E402 --max-line-length=120 {} +
if [ $? -ne 0 ]; then
>&2 echo "=== PEP8 errors need to be solved ==="
else
echo "=== PEP8 check ok ==="
fi
pytest
Run Code Online (Sandbox Code Playgroud)
但是,有一些事情要么没有签入,要么被.gitignore编辑.所以我想获取输出git ls-files并仅在那些上运行命令.我可以循环,但我不想对开发人员选择的shell做出假设.理想情况下,我想find通过设置差异来过滤s输出git ls-files.