opencv3.3出炉,与深度学习结合更密切

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/HelloHaibo/article/details/77714242

opencv3.3在八月3号发布,日志中说到:

The main news is that we promoted DNN module from opencv_contrib to the main repository, improved and accelerated it a lot.For GPU there is experimental DNN acceleration using Halide.

这可是个好消息,OpenCV 3.3 使用了加速的 dnn 模块,并将其移动到了主存储库,这也是首次在 OpenCV 中出现 Halide,带来了多项优化和其他的改进。

OpenCV can now be built as C++ 11 library using the flag ENABLE_CXX11. Some cool features for C++ 11 programmers have been added.

除此之外,新版本还对C++11有了更完善的支持,比如:

// 1. use parallel_for_ with lambda to compute Mandelbrot fractal
parallel_for_(Range(0, img.rows*img.cols), [&](const Range& r) {
    for (int r = r.start; r < r.end; r++) {
        int i = r/img.cols, j = r%img.cols, t, maxiter=500;
        complex<float> z0(j * 2.7f/img.cols – 2.1f,
                          i * 2.4f/img.rows – 1.2f);
        for (t = 0; t < maxiter; t++) {
            if (z.real()*z.real()+z.imag()*z.imag()> 4.f) break;
            z = z*z + z0;
        }
        img.at<uchar>(i, j)=uchar(sqrt((float)t/maxiter)*255);
}});

// 2. using C++ 11 initializers
auto A = Mat_<double>({0, -1, 0, -1, 5, -1, 0, -1, 0}).reshape(1, 3);
Vec_<int, 10> digits = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

// 3. apply LUT to 8-bit image in C++ 11 style
Mat_<Vec3b> img = imread("lena.jpg");
for( auto& pixel: img ) {
    pixel[0] = gamma_lut[pixel[0]];
    pixel[1] = gamma_lut[pixel[1]];
    pixel[2] = gamma_lut[pixel[2]];
}
对于DL在opencv中的使用,官方wiki发布:

The supported frameworks:

Caffe 1
TensorFlow
Torch/PyTorch
The supported layers:
AbsVal
AveragePooling
BatchNormalization
Concatenation
Convolution (including dilated convolution)
Crop
Deconvolution, a.k.a. transposed convolution or full convolution
DetectionOutput (SSD-specific layer)
Dropout
Eltwise (+, *, max)
Flatten
FullyConnected
LRN
LSTM
MaxPooling
MaxUnpooling
MVN
NormalizeBBox (SSD-specific layer)
Padding
Permute
Power
PReLU (including ChannelPReLU with channel-specific slopes)
PriorBox (SSD-specific layer)
ReLU
RNN
Scale
Shift
Sigmoid
Slice
Softmax
Split
TanH
The following networks have been tested and known to work:
AlexNet
GoogLeNet v1 (also referred to as Inception-5h)
ResNet-34/50/...
SqueezeNet v1.1
VGG-based FCN (semantical segmentation network)
ENet (lightweight semantical segmentation network)
VGG-based SSD (object detection network)
MobileNet-based SSD (light-weight object detection network)
现在可以直接使用opencv去调用深度学习框架训练好的模型参数,比如caffemodel、tensorflow等等。

展开阅读全文

没有更多推荐了,返回首页