我在c:/../ Opencv 3.0和ms visual studio 2012安装(解压缩)opencv。我使用cmake创建库。 cmake中构建二进制文件的路径 - > c:/ opencv / build custom /,它与opencv路径不同。我在cmake中选择了visual studio 11 2012。
还设置环境路径。
在物业经理我设置c / c ++>一般> AdditionalIncludeDirectories:
C:\懒惰\的OpenCV \构建\包括;%
链接器>一般> AdditionalLibraryDirectories:C:\ opencv \ build_custom \ lib \ Debug;%
链接器>输入> AdditionalDependencies:opencv_calib3d300d.lib; opencv_core300d.lib; opencv_features2d300d.lib; opencv_flann300d.lib; opencv_highgui300d.lib; opencv_imgproc300d.lib; opencv_ml300d.lib; opencv_objdetect300d.lib; opencv_photo300d.lib; opencv_stitching300d.lib; opencv_superres300d.lib; opencv_ts300d.lib; opencv_video300d.lib; opencv_videostab300d.lib;
我在ms visual studio中使用下面的svm代码:
#include <stdio.h>
#include <math.h>
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <opencv2\objdetect\objdetect.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <vector>
#include <windows.h>
#include <atlstr.h>
#include <iostream>
#include <sstream>
#include <iomanip>
//#include <opencv2\imgproc\imgproc.hpp>
#include <opencv2\core\core.hpp>
//#include <opencv2\highgui\highgui.hpp>
#include <opencv\cvaux.hpp>
using namespace cv;
using namespace std;
#include <opencv2\ml.hpp>
using namespace cv;
int main()
{
// Data for visual representation
int width = 512, height = 512;
Mat image = Mat::zeros(height, width, CV_8UC3);
// Set up training data
int labels[4] = { 1, -1, -1, -1 };
Mat labelsMat(4, 1, CV_32FC1, labels);
float trainingData[4][2] = { { 501, 10 }, { 255, 10 }, { 501, 255 }, { 10, 501 } };
Mat trainingDataMat(4, 2, CV_32FC1, trainingData);
// Set up SVM's parameters
Ptr<ml::SVM> svm = ml::SVM::create();
// edit: the params struct got removed,
// we use setter/getter now:
svm->setType(ml::SVM::C_SVC);
svm->setKernel(ml::SVM::LINEAR);
svm->setGamma(3);
svm->train(trainingDataMat, ml::ROW_SAMPLE, labelsMat);
Mat res; // output
Vec3b green(0, 255, 0), blue(255, 0, 0);
// Show the decision regions given by the SVM
for (int i = 0; i < image.rows; ++i)
for (int j = 0; j < image.cols; ++j)
{
Mat sampleMat = (Mat_<float>(1, 2) << j, i);
float response = svm->predict(sampleMat, res);
if (response == 1)
image.at<Vec3b>(i, j) = green;
else if (response == -1)
image.at<Vec3b>(i, j) = blue;
}
// Show the training data
int thickness = -1;
int lineType = 8;
circle(image, Point(501, 10), 5, Scalar(0, 0, 0), thickness, lineType);
circle(image, Point(255, 10), 5, Scalar(255, 255, 255), thickness, lineType);
circle(image, Point(501, 255), 5, Scalar(255, 255, 255), thickness, lineType);
circle(image, Point(10, 501), 5, Scalar(255, 255, 255), thickness, lineType);
// Show support vectors
thickness = 2;
lineType = 8;
Mat sv = svm->getSupportVectors();
for (int i = 0; i < sv.rows; ++i)
{
const float* v = sv.ptr<float>(i);
circle(image, Point((int)v[0], (int)v[1]), 6, Scalar(128, 128, 128), thickness, lineType);
}
imwrite("result.png", image); // save the image
imshow("SVM Simple Example", image); // show it to the user
waitKey(0);
}
调试时出错了。 这是错误,我在运行程序时得到了
如何解决?
答案 0 :(得分:2)
$(document).on('change', ".serialnotd", function () {
var count = $("[type='checkbox']:checked").length;
var qty = $(this).parent().children().find('.recqantity').val();
var isssue_qty = parseInt(qty);
var select_qty = parseInt(count);
if (select_qty > isssue_qty) {
alert("Selected no's. must be equal to Qty");
}
if (select_qty >= isssue_qty) {
$('input[type=checkbox]').not(':checked').attr("disabled", true);
} else {
$('input[type=checkbox]').not(':checked').attr("disabled", false);
}
})
just changed
var count = $("[type='checkbox']:checked").length;
to
var count = $(this).find('input[type="checkbox"]:checked').length;
函数在imwrite
中,将其添加到AdditionalDependencies