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
标签云
Streamlit BTC Math NameSilo Harness Data Search Google Numpy SVR LLM LaTeX OpenCV XML Quantization 递归学习法 GIT 继承 Disk XGBoost diffusers Hotel Pandas hf Website Markdown 多线程 Shortcut Transformers WebCrawler OCR Base64 Jupyter GoogLeNet Git Rebuttal ResNet-50 ModelScope News 公式 PIP Review LeetCode CEIR CAM Freesound 个人博客 关于博主 torchinfo Ptyhon PyTorch 版权 证件照 顶会 Bitcoin 论文 Jetson PyCharm Dataset Random tqdm API CSV 域名 Anaconda Qwen2.5 Github Django Statistics Tracking MD5 Qwen2 Image2Text HaggingFace Interview 阿里云 TensorRT Pillow IndexTTS2 Domain Video SPIE Attention Plate Sklearn Python Cloudreve RL Hilton TSV Nginx WAN UI Paddle 长期记忆 Tiktoken Llama Algorithm v0.dev Bin VGG-16 mmap Ubuntu API网关 Michelin 腾讯云 图标 Hungarian PDB uWSGI OpenAI SQL Tensor v2ray DeepSeek Paper 自我改进 Gemma Crawler Augmentation VSCode 飞书 Agent 算法题 Pytorch FP64 Miniforge git Mixtral Use JSON icon COCO scipy 搞笑 LoRA CTC InvalidArgumentError Vim Knowledge Web RGB Password Safetensors Permission ONNX tar 净利润 FlashAttention Zip SQLite 音频 Heatmap TensorFlow Clash Vmess Docker llama.cpp Color printf BeautifulSoup Translation Breakpoint RAR ms-swift Proxy 签证 C++ Bert TTS 第一性原理 AI VPN CV GGML NLP Firewall git-lfs CUDA LLAMA QWEN 多进程 Plotly Card Distillation 图形思考法 FastAPI Baidu Quantize Land NLTK PDF UNIX 论文速读 FP16 YOLO transformers BF16 uwsgi Windows Magnet CLAP 云服务器 HuggingFace Jev Claude Conda Bipartite Linux 财报 Excel Datetime ChatGPT DeepStream logger Food EXCEL Input FP32 Diagram 强化学习 CC Qwen Pickle 报税 SAM GPTQ GPT4 Template Logo Animate FP8
站点统计

本站现有博文340篇,共被浏览1019355次

本站已经建立2719天!

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