I run imdecode on both c++ and csharp, but csharp is faster than c++, is that right?
(In my opinion, csharp just call c++ dll so it should slower than or the same speed as c++)
Environment
win 11, opencv 4.7, .net4.8
What did you do when you faced the problem?
Write here
Example code:
c++
std::string img_path = "E:/1.jpg";
cv::Mat cvimg = cv::imread(img_path);
double start, end;
double tot_cv = 0;
int times = 100;
std::vector<uchar> buf;
cv::imencode(".jpg", cvimg, buf);
cv::Mat t1 = cv::imdecode(buf, IMREAD_ANYCOLOR);
for (int i = 0; i < times; i++) {
start = static_cast<double>(cv::getTickCount());
cv::Mat cvres = cv::imdecode(buf, IMREAD_ANYCOLOR);
end = static_cast<double>(cv::getTickCount());
tot_cv += (end - start) * 1000 / cv::getTickFrequency();
}
std::cout << "imdecode avg time : " << tot_cv / times << std::endl;
Summary of your issue
I run imdecode on both c++ and csharp, but csharp is faster than c++, is that right? (In my opinion, csharp just call c++ dll so it should slower than or the same speed as c++)
Environment
win 11, opencv 4.7, .net4.8
What did you do when you faced the problem?
Write here
Example code:
c++
csharp
Output:
On my computer, c++ runs 34ms while csharp runs 16ms. It means csharp imdecode doesn't call c++ imdecode actually? Can anyone explain this? Thanks.
What did you intend to be?