Write C++ code to convert GIF to opencv Mat and back -- 2
Budget: $30 – $250 USD
You need to code the methods decode_gif and encode_gif in the example code below.
You don't need to check that the input file contains a GIF image, and you don't need to support any other image formats - only GIF.
Each image (video frame) of the decoded GIF should be stored in the vector of cv:Mat in the order they appear in the GIF.
Your code needs to run on Ubuntu 20.04 (built with gcc 9) and Windows 10 (built with VS2022).
You may (and should) use existing and trusted open source code that is already available.
However, your code must not depend on any library or installation once compiled.
You should compile and link any external sources you need into this project.
Try to keep any external linkage to the minimum number of files. However, you may link the full opencv if you need any of it.
If you need to modify external sources for this to work please provide the changes. Preferably in a git commit.
Please provide a CMakeLists.txt file to build your code.
Please provide a walkthrough describing how to get and install whatever you use.
#include <opencv2/core.hpp>
#include <fstream>
#include <vector>
#include <string>
class Trial {
static std::vector<cv::Mat> decode_gif(const std::string& image_content);
static std::string encode_gif(std::vector<cv::Mat> image);
void Test(){
std::ifstream stream("test.gif", std::ios::in | std::ios::binary);
auto image_content = std::string(std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>());
auto mat = decode_gif(image_content);
auto after = encode_gif(mat);
std::ofstream out("after.gif");
out << after;
out.close();
}
};
You don't need to check that the input file contains a GIF image, and you don't need to support any other image formats - only GIF.
Each image (video frame) of the decoded GIF should be stored in the vector of cv:Mat in the order they appear in the GIF.
Your code needs to run on Ubuntu 20.04 (built with gcc 9) and Windows 10 (built with VS2022).
You may (and should) use existing and trusted open source code that is already available.
However, your code must not depend on any library or installation once compiled.
You should compile and link any external sources you need into this project.
Try to keep any external linkage to the minimum number of files. However, you may link the full opencv if you need any of it.
If you need to modify external sources for this to work please provide the changes. Preferably in a git commit.
Please provide a CMakeLists.txt file to build your code.
Please provide a walkthrough describing how to get and install whatever you use.
#include <opencv2/core.hpp>
#include <fstream>
#include <vector>
#include <string>
class Trial {
static std::vector<cv::Mat> decode_gif(const std::string& image_content);
static std::string encode_gif(std::vector<cv::Mat> image);
void Test(){
std::ifstream stream("test.gif", std::ios::in | std::ios::binary);
auto image_content = std::string(std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>());
auto mat = decode_gif(image_content);
auto after = encode_gif(mat);
std::ofstream out("after.gif");
out << after;
out.close();
}
};