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

本站现有博文339篇,共被浏览995708次

本站已经建立2706天!

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