I have a strange problem. I'm training a pca with a vector of data (Mat myData) as such:
我有一个奇怪的问题。我正在用一个数据向量(Mat myData)训练一个pca:
PCA pca(myData, Mat(), CV_PCA_DATA_AS_ROW, 90);
The number of rows in myData coresponds to the number of samples. The strange thing is that if I train the PCA on about 90 samples it runs no problem but when I increase the number of sample it gives me the error:
myData中的行数与样本数相对应。奇怪的是,如果我在大约90个样本上训练PCA,它运行没有问题,但是当我增加样本数量时它会给我错误:
Microsoft C++ exception: cv::Exception at memory location
Microsoft C ++异常:cv ::内存位置的异常
When I run the same code on Linux machine it also runs without any problems.
当我在Linux机器上运行相同的代码时,它也运行没有任何问题。
Does anyone have an idea what is wrong?
有谁知道出了什么问题?
1 个解决方案
#1
0
The most likely reason is that the input doesn't contain as much data as you'd think it does. As a result, OpenCV will perform an out-of-bound memory access.
最可能的原因是输入不包含您认为的数据量。因此,OpenCV将执行越界内存访问。
This is Undefined Behavior, and is very likely to have different results on different systems. Simply using one element too much often is undetected by the OS, and your PCA won't be excessively wrong because of it.
这是未定义的行为,很可能在不同的系统上有不同的结果。操作系统通常不会过多地使用一个元素,因此您的PCA不会过分错误。
#1
0
The most likely reason is that the input doesn't contain as much data as you'd think it does. As a result, OpenCV will perform an out-of-bound memory access.
最可能的原因是输入不包含您认为的数据量。因此,OpenCV将执行越界内存访问。
This is Undefined Behavior, and is very likely to have different results on different systems. Simply using one element too much often is undetected by the OS, and your PCA won't be excessively wrong because of it.
这是未定义的行为,很可能在不同的系统上有不同的结果。操作系统通常不会过多地使用一个元素,因此您的PCA不会过分错误。