Closed wangzhankun closed 3 years ago
I even defined #define SIMD_OPENCV_ENABLE in the SimdView.hpp, but it dose nothing.
Hi!
What is type of img.resource
?
Try to do something like this:
cv::Mat src = img.resource;
Simd::View viewSrc = src;
img.resource
is cv::Mat
type. And now I find the reason. I have to typedef View firstly, typedef Simd::View<Simd::Allocator> View;
. But yesterday I don't know that.
I have another question, if simd
have implemented cv::inRange
function? I have a need that I want convert RGB into HSV and then execute cv::inRange
function. I find that I cannot use cv_mat_hsv = simd_view_hsv
to convert View
into cv:Mat
type and use the cv::inRange
function.
Unfortunately, there is no function in Simd with described functionality.
But why cannot convert View
in HSV color space into cv::Mat
in HSV color space? I think there is no special data structure in Simd::View
or cv::Mat
since that you have implemented the function View
to Mat
in RGB color space.
You can use another type of Simd::View constructor:
/*!
Creates a new View structure with specified width, height, row size, pixel format and pointer to pixel data.
\param [in] w - a width of created image view.
\param [in] h - a height of created image view.
\param [in] s - a stride (row size) of created image view.
\param [in] f - a pixel format of created image view.
\param [in] d - a pointer to the external buffer with pixel data.
If this pointer is NULL then will be created own buffer.
*/
View(size_t w, size_t h, ptrdiff_t s, Format f, void * d);
It is more universal method to create View:
View view(mat.cols, mat.rows, mat.step[0], View::Hsv24, mat.data);
Sorry for my poor English. I confused you.
typedef Simd::View<Simd::Allocator> View;
View view_tmp = this->src_img;
View dst(this->src_img.cols, this->src_img.rows, Simd::View<Simd::Allocator>::Format::Hsv24);
cout << dst.Size().x << " " << dst.Size().y << endl;
Simd::BgrToHsv(view_tmp, dst);
cout << "hello" << endl;
Mat tmp = dst;
// Mat tmp;
cout << "world" << endl;
At the 7th line there is an issue when running:
/usr/local/include/Simd/SimdView.hpp:1142: static int Simd::View<A>::ToOcv(Simd::View<A>::Format) [with A = Simd::Allocator]: Assertion `0' failed.
error: execv(/home/wang/Documents/ComputerVision/build/linux/x86_64/debug/CV) failed(-1)
I want to know how to convert View
in HSV color space into cv::Mat
?
You can use universal constructor for output View too.
typedef Simd::View<Simd::Allocator> View;
View src = this->src_img;
Mat tmp(this->src_img.cols, this->src_img.rows, CV_8UC3);
View dst(tmp.cols, tmp.rows, tmp.step[0], View::Hsv24, tmp.data);
Simd::BgrToHsv(src, dst);
or use С API function:
Mat tmp(this->src_img.cols, this->src_img.rows, CV_8UC3);
SimdBgaToHsv(this->src_img.data, this->src_img.cols, this->src_img.rows, this->src_img.step[0], tmp.data, tmp.step[0]);
It seems that Simd::BgrToHsv
is much slower than cv::cvtColor
, although Simd::Resize
is a little faster than cv::resize
. But also for you patience on answering my question and your work on simd. Thanks.
As I can see there is no optimizations for Sims::BgrToHsv. I did not use this function widely before.
I have included the
Simd/SimdLib.hpp
, and I defined#define SIMD_OPENCV_ENABLE
, but when I build, I run into error.error