我想dlib用python进行图像识别.我在Windows 10上使用OpenCV运行的python应用程序很棒,但是当我想dlib从cmd它安装它时会出现以下错误:
错误:找不到cmake,确保它已安装并且在路径中.您可以使用https://cmake.org/install/上的说明安装cmake. 您也可以使用--cmake参数指定其路径.
我该怎么办?
我想知道 python 或 perl 中是否有任何方法可以构建一个正则表达式,您可以在其中定义一组选项,这些选项最多可以以任何顺序出现一次。例如,我想要 的导数foo(?: [abc])*,其中a, b,c只能出现一次。所以:
foo a b c
foo b c a
foo a b
foo b
Run Code Online (Sandbox Code Playgroud)
都是有效的,但是
foo b b
Run Code Online (Sandbox Code Playgroud)
不会是
我想在虚拟内存的末尾创建一个带有特殊部分的程序.所以我想做一个像这样的链接器脚本:
/* ... */
.section_x 0xffff0000 : {
_start_section_x = .;
. = . + 0xffff;
_end_section_x = .;
}
Run Code Online (Sandbox Code Playgroud)
的问题是,GCC/LD/glibc的似乎在该位置处由默认32位应用程序加载堆栈,即使它重叠的已知部分.上面的代码为0,导致异常.有没有办法告诉链接器为堆栈使用另一个VM内存位置?(同样,我想确保堆不会跨越虚拟内存的这一部分......).
我想知道测试命名捕获组是否存在的正确方法是什么。具体来说,我有一个函数将编译的正则表达式作为参数。正则表达式可能有也可能没有特定的命名组,并且命名组可能会也可能不会出现在传入的字符串中:
some_regex = re.compile("^foo(?P<idx>[0-9]*)?$")
other_regex = re.compile("^bar$")
def some_func(regex, string):
m = regex.match(regex, string)
if m.group("idx"): # get *** IndexError: no such group here...
print(f"index found and is {m.group('idx')}")
print(f"no index found")
some_func(other_regex, "bar")
Run Code Online (Sandbox Code Playgroud)
我想测试该组是否存在而不使用try-- 因为这会短路函数的其余部分,如果找不到指定的组,我仍然需要运行该函数。
听起来我应该可以使用Google,但找不到很好的参考。到底是__attribute__((force))做什么的?如:
return (__attribute__((force)) uint32_t) *p
Run Code Online (Sandbox Code Playgroud)
(这是针对使用clang交叉编译的ARM系统,但是即使在clang / arm特定页面中,我也找不到此属性的任何引用。)
我有一个非常大且复杂的 make 系统,需要几个小时才能完成。我正在研究潜在的优化,我有一个关于是否可以优先考虑某些目标的问题。
下面是一个简单的 Makefile 示例,它说明了这个概念:
Test%: Prog%
#run some post build verification on Prog{n}
# -- takes 30min or less on failure...
Prog1: A B
# do some linking
Prog2: B C
# do some linking
A B C:
# take 10 minutes each
Run Code Online (Sandbox Code Playgroud)
然后我跑
make -j2 Prog1 Test2
Run Code Online (Sandbox Code Playgroud)
那么构建它的最快方法是:B& C,然后是Prog2& A,然后是Test2and Prog2。当然,通常情况下,化妆将建立A和B第一,这将减少10分钟耽误我最终输出。
如果我预知这Test2将成为瓶颈,是否可以将该目标及其所有依赖项优先于 gnu make 中的其他目标?
要添加的问题,比方说我要建Test1,Test2...... Test20。那么在这种情况下,我希望其中一个目标 …
我想处理在 linux 中完成的编译的输出,并将所有错误引用转换为使用可以由 windows IDE 解析的 dos 文件路径。例如,如果我在 unix 文件中有以下行:
linuxroot/a/b/c/file.c:200:1: error: evil use of / character
Run Code Online (Sandbox Code Playgroud)
我希望它输出:
d:\sftp\a\b\c\file.c:200:1: error: evil use of / character
Run Code Online (Sandbox Code Playgroud)
所以基本上,我想找到任何匹配的东西:^\(linuxroot/[A-Za-z0-9_/.-]*\):[0-9]*:[0-9]*: error: \(.*\)$,然后通过另一个 sed 替换仅运行第一组:
sed -e "s|\/|\\\\|g" -e "s|^\\\\linuxroot|d:\\\\sftp"。sed 中有什么机制可以做这样的事情吗?
我有一些类似于以下内容的代码:
void somefunc(uint64_t val) {
uint8_t *p;
uint8_t *s;
s = calloc( (max_sa_len + sizeof(uint64_t) - 1) / sizeof(uint64_t), sizeof(uint64_t));
// s must be 8 byte aligned here
p = (s + sizeof(uint64_t));
// p must be 8 byte aligned here
*(uint64_t)*p = hton64(val & 0xffff);
...
}
Run Code Online (Sandbox Code Playgroud)
当我编译时,我得到:
file.c:400:10: error: cast increases required alignment of target type [-Werror=cast-align]
Run Code Online (Sandbox Code Playgroud)
有没有一种干净的方法来解决这个警告? s,因此p 必须与 64 位地址对齐,这不是真正的错误。我尝试p=__builtin_assume_alinged(p,8);在代码中添加一个,但它没有修复错误。我在使用 arm32 (v7) gcc 交叉编译器 v 4.7.0 时遇到此错误
我正在尝试根据一些输入在 perl 中自动生成一个正则表达式模式,以处理通过在 Makefile 中粘贴令牌创建的各种变量......因此,例如,我可能有一个模式,例如:
foo_1_$(AB)_$(CB)
Run Code Online (Sandbox Code Playgroud)
鉴于这种模式,我需要创建一个正则表达式,将所有实例转换foo_1_\$(\w+)_\$(\w+)为bar_1_\$($1)_\$($2). 我遇到的主要问题是模式的“to”端——我$每次都需要增加数字引用——注意在任何给定模式中可能有可变数量的标记。
所以......我在想这样的事情:
foreach $pattern (@patterns) {
my $from = $pattern;
# foo_1_$(AB)_$(CD)
$from =~ s/\$\(\w+\)/\$\(\\w\\\+\)/g;
# foo_1_$(\w+)_$(\w+)
my $to = $pattern =~ s/foo/bar/r;
# bar_1_$(AB)_$(CD);
$to =~ s/\$\(\w+\)/\\\$\(\$?)/g; #???
# bar_1_\$($1)_\$($2)
# ^ ^
#this next part is done outside of this loop, but for the example code:
$line ~= s/\Q$from\E/$to/;
}
Run Code Online (Sandbox Code Playgroud)
如何使我的每个后续替换to具有增量索引?
我需要替换 perl 中的一些字符串,这些字符串以$字符开头并以). 因此,例如替换$(FOO)为FOO. 我不想匹配像$(FOO)_BLAHorBLAH_$(FOO)或 $(FOO)$(BAR) 这样的东西,但我确实想匹配$($(FOO)). 我不能\b在我的正则表达式中使用,因为 the$或 the)实际上不是单词字符。不过,我想做一些等效的事情。我想出了:
/([^\w\$\)_]|^)\$\(FOO\)([^\w\$\(_]|$)/$1FOO$2/
Run Code Online (Sandbox Code Playgroud)
这看起来很乱(特别是我不喜欢正则表达式中的$1and $2。我只是想知道是否有更干净的方法来做到这一点。
我有一个简单的 bash 函数hle(突出显示错误),它在构建时突出显示重要文本。它的实现如下:
hle() (
set -o pipefail
"$@" 2>&1 |
sed -f $hldir/red.sed -f $hldir/blue.sed -f $hldir/orange.sed
)
Run Code Online (Sandbox Code Playgroud)
所以你可以运行hle make target,所有错误都显示为红色,警告为橙色,调试为蓝色
现在,我有一个执行以下操作的脚本:
foo.sh:
eval hle $command
[ $? ] && echo "SUCCESS"
Run Code Online (Sandbox Code Playgroud)
但这并不$?代表 eval 的返回代码(我相信这是 hle 本身的返回代码......)我将如何保留$command脚本中的返回代码?