gpt4 book ai didi

c++ - 为什么字符 ÌÌÌÌ 卡在我的字符串开头?

转载 作者:太空狗 更新时间:2023-10-29 23:47:54 30 4
gpt4 key购买 nike

我一直在使用 openCV 开发一些计算机视觉工具,但每次我将字符串传递给 openCV 函数时,字符 ÌÌÌÌ 都会被标记到开头。起初这很烦人,但现在我正在尝试使用 openCV 的文件存储工具,而 ÌÌÌÌ 字符使我的文件名变得不可读。

注意:只有当我将字符串传递给新的 C++ 样式的 openCV 函数时,字符才会被添加。如果我使用旧的 C 风格函数,字符串会很好。

例子:我输入这个:

namedWindow("CBImage", 1);
.
.
.
imshow("CBImage", Frame);

但是窗口标题显示为ÌÌÌÌCBImage

我不认为这个问题一定是 openCV 特有的;我认为这与一般的字符串使用有关。检查此链接,编码器似乎遇到了类似的问题。 http://www.sfml-dev.org/forum/viewtopic.php?t=1257&sid=5cfa50b780e47685d1c03296adffa8ed

有什么想法吗?谢谢


谢谢大家的帮助。 KennyTM 最初的建议确实解决了这个问题。我不得不用调试版本替换我的 cv cvaux cvcore 和 highgui 库(它们可能必须根据您运行的 openCV 版本来构建,检查您的 openCV 目录中的 lib 文件夹)。

最佳答案

Given that ÌÌÌÌ = 0xCCCCCCCC ,似乎库不希望字符串成员之前有 4 字节成员,例如

// Provided.
struct something {
...
void* some_pointer; // uninitialized variables are filled with 0xCC in debug mode.
char the_actual_content[1234];
...
}

// But the library wants
struct something {
...
char the_actual_content[1234]; // now the 0xCCCCCCC is shifted into this string.
...
}

您是否尝试过链接中的建议?

Don't mix debug and release configurations If you're in debug mode, link to the libraries with the "-d" suffix.

关于c++ - 为什么字符 ÌÌÌÌ 卡在我的字符串开头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3313023/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com