OpenCV、EmguCV和OpenCvSharp指针访问图像像素值耗时测评(附源码)

背景介绍

    EmguCV和OpenCvSharp都是OpenCV在.Net下的封装,常常会听到有人说EmguCV或OpenCvSharp同样的函数比OpenCV函数运行速度慢,到底是不是真的?博主暂时也没有去一一验证,本文主要对比下三者用指针方法读取像素的速度、耗时情况。

对比实验说明

    提供2张图片做测试,分辨率分别是3000 x 3835 和 600 x 676:

分别使用OpenCV、EmguCV和OpenCvSharp指针方法来读取修改像素值,并计算所用时间。

【1】OpenCV测试

        代码如下:

// Read_Modify_Piexl_Value.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include "pch.h"
#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

Mat readPixelNormal(Mat img, Mat thres)
{
	for (int i = 0; i < thres.rows; i++)
	{
		for (int j = 0; j < thres.cols; j++)
		{
			if (thres.at<uchar>(i, j) == 255)
			    img.at<Vec3b>(i, j

猜你喜欢

转载自blog.csdn.net/stq054188/article/details/125770694
今日推荐