EADST

C++: Copy ROI and Add Padding

Recently, I did some data augmentation work with C++ OpenCV. Here is one example.

// load image
string test_path = "D:\\test.jpg";
cv::Mat img = cv::imread(test_path, CV_8UC3);
// crop image and get ROI
cv::Rect r(5, 5, 25, 25);
cv::Mat roi = img(r).clone();
cv::imwrite("test_cropped.jpg", roi);
// set padding background
int padding = 20;
cv::Mat img_pad = cv::Mat::zeros(roi.rows + padding * 2, roi.cols + padding * 2, CV_8UC3);
img_pad.setTo(cv::Scalar(255, 255, 255));
// pad image
cv::Rect roi_rect = cv::Rect(padding, padding, roi.cols, roi.rows);
roi.copyTo(img_pad(roi_rect));
cv::imwrite("test_padded.jpg", img_pad);
相关标签
C++
About Me
XD
Goals determine what you are going to be.
Category
标签云
LLAMA v2ray Template Permission Hotel 公式 UI Breakpoint Datetime 关于博主 LeetCode tqdm Miniforge Bipartite Translation XGBoost Website 多线程 Knowledge 强化学习 Land 签证 Github Linux Bitcoin SAM Pytorch Zip Crawler logger Agent Input GPT4 TensorFlow Streamlit CSV Hungarian SQLite 搞笑 NLP CV 净利润 uwsgi Tiktoken Use PyTorch ChatGPT EXCEL CUDA Augmentation CEIR Google Review Hilton Animate Paddle hf Bert WAN git Django YOLO Logo ResNet-50 Random 继承 Domain Data SVR Clash Qwen2.5 Baidu Image2Text 顶会 第一性原理 Anaconda DeepSeek TSV FP8 CLAP QWEN API Tracking 报税 Vim Pillow Interview Pandas Algorithm Git Qwen2 RL 论文速读 Heatmap Diagram Cloudreve BTC llama.cpp FP32 PIP Excel COCO Card printf Rebuttal 证件照 ONNX UNIX Windows LLM XML Qwen MD5 BeautifulSoup uWSGI Nginx BF16 Tensor 论文 TensorRT GPTQ Markdown 算法题 Pickle Vmess Math HuggingFace Color 阿里云 v0.dev Shortcut icon RGB 飞书 PDB Jetson FP16 FastAPI 图标 VPN Web 云服务器 Quantize Ptyhon Conda Jupyter 财报 CTC Plotly NameSilo NLTK TTS Dataset 音频 diffusers Bin IndexTTS2 SQL Video GIT PDF Distillation Password Python SPIE 版权 OCR Gemma VSCode 腾讯云 Statistics Safetensors DeepStream Proxy scipy RAR 域名 Ubuntu InvalidArgumentError Llama C++ git-lfs AI Quantization Food tar OpenCV mmap Plate Attention Firewall CC GGML Numpy News 递归学习法 VGG-16 torchinfo Search Disk JSON ModelScope Transformers 多进程 PyCharm LoRA FP64 Freesound Base64 transformers OpenAI Mixtral CAM Docker Michelin WebCrawler Sklearn HaggingFace FlashAttention ms-swift GoogLeNet Paper LaTeX 图形思考法 Claude Magnet
站点统计

本站现有博文332篇,共被浏览873819

本站已经建立2581天!

热门文章
文章归档
回到顶部