Viper666
31st January 2013, 18:40
Hi everybody i have a problem
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <QtCore>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat src = imread(String("qrc://balls.jpg"), CV_LOAD_IMAGE_COLOR);
if (src.empty())
{
cout << "cannot load" << endl;
return -1;
}
Mat hsv;
cvtColor(src, hsv, CV_BGR2HSV);
Mat bw;
inRange(hsv, Scalar(19, 204, 153), Scalar(27, 255, 255), bw);
vector<vector<Point> > contours;
findContours(bw.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
Mat dst = Mat::zeros(src.size(), src.type());
drawContours(dst, contours, -1, Scalar::all(255), CV_FILLED);
dst &= src;
imshow("src", src);
imshow("dst", dst);
waitKey(0);
int a;
cin >> a;
return 0;
}
and resource file
<RCC>
<qresource prefix="/">
<file>balls.jpg</file>
</qresource>
</RCC>
but it never load image i dont know what is wrong
But QImage load it but i dont know how convert it to Mat static_cast doesnt work
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <QtCore>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat src = imread(String("qrc://balls.jpg"), CV_LOAD_IMAGE_COLOR);
if (src.empty())
{
cout << "cannot load" << endl;
return -1;
}
Mat hsv;
cvtColor(src, hsv, CV_BGR2HSV);
Mat bw;
inRange(hsv, Scalar(19, 204, 153), Scalar(27, 255, 255), bw);
vector<vector<Point> > contours;
findContours(bw.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
Mat dst = Mat::zeros(src.size(), src.type());
drawContours(dst, contours, -1, Scalar::all(255), CV_FILLED);
dst &= src;
imshow("src", src);
imshow("dst", dst);
waitKey(0);
int a;
cin >> a;
return 0;
}
and resource file
<RCC>
<qresource prefix="/">
<file>balls.jpg</file>
</qresource>
</RCC>
but it never load image i dont know what is wrong
But QImage load it but i dont know how convert it to Mat static_cast doesnt work