function out = resnet50_wrapper(im,ocvFlag) %#codegen
% Wrapper function to call ResNet50 predict function.

%   Copyright 2019-2021 The MathWorks, Inc.

% This example uses OpenCV for reading frames from a web camera and
% displaying output image. Update buildinfo to link with OpenCV library
% available on target.
if ocvFlag
    opencv_link_flags = '`pkg-config --libs opencv4`';
    opencv_compile_flags = '`pkg-config --cflags  opencv4`';
else
    opencv_link_flags = '`pkg-config --libs opencv`';
    opencv_compile_flags = '`pkg-config --cflags --libs opencv`';
end

coder.updateBuildInfo('addLinkFlags',opencv_link_flags);
coder.updateBuildInfo('addCompileFlags',opencv_compile_flags);

% To avoid multiple loads of the network for each run, we use persistent
% rnet
persistent rnet;
if isempty(rnet)
    rnet = resnet50();
end
out = rnet.predict(im);

end