【问题标题】:could not figure out '\u202A' warning while running my opencv code in visual studio 2012在 Visual Studio 2012 中运行我的 opencv 代码时无法找出“\u202A”警告
【发布时间】:2015-05-03 06:13:34
【问题描述】:

我不断收到此警告

Warning 1 警告 C4566: 由通用字符名 '\u202A' 表示的字符无法在当前代码页中表示 (1252) C:\Users\ankitdeora2856\Downloads\opencvFiles\main.cpp 1088

在 Visual Studio 2012 中以 c++ 运行我的 opencv 代码时。我的代码正在构建且没有任何错误,但此警告会产生问题,无法获得预期的输出。我正在尝试使用 addweighted() 函数添加两个图像,但由于此警告而没有得到输出。

#include <cv.h>
#include <highgui.h>
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
 double alpha = 0.5; double beta; double input;
 Mat src1, src2, dst;

 /// Ask the user enter alpha
 std::cout<<" Simple Linear Blender "<<std::endl;
 std::cout<<"-----------------------"<<std::endl;
 std::cout<<"* Enter alpha [0-1]: ";
 std::cin>>input;

 /// We use the alpha provided by the user if it is between 0 and 1
 if( input >= 0.0 && input <= 1.0 )
   { alpha = input; }

 /// Read image ( same size, same type )
 src1 = imread("‪pic1.jpg");
 src2 = imread("‪pic2.jpg");

 if( !src1.data ) { printf("Error loading src1 \n"); return -1; }
 if( !src2.data ) { printf("Error loading src2 \n"); return -1; }

 /// Create Windows
 namedWindow("Linear Blend", 1);

 beta = ( 1.0 - alpha );
 addWeighted( src1, alpha, src2, beta, 0.0, dst);

 imshow( "Linear Blend", dst );

 waitKey(0);
 return 0;
}

【问题讨论】:

  • 有人在 " 和 pic1.jpg 之间插入了UTF-8 sequence E2 80 AA,只需重写这一行。下一行也是如此
  • 当然,如果实际文件名包含这些字符,您还需要重命名文件,否则将找不到。

标签: c++ opencv visual-studio-2012


【解决方案1】:

UTF-8 字符 ('\u202A' ) 在您的代码中某处,但在您当前的编码中看不到。

我也遇到了这个问题,为了解决这个问题,我将代码粘贴到 Notepad++ 中,然后在顶部的 Encoding 下将其更改为 ANSI,隐藏的字符出现了,我能够删除它们并将结果粘贴回 Visual工作室。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-06
    • 2013-11-03
    • 2020-05-26
    • 2021-04-03
    • 1970-01-01
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多