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

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

本站已经建立2583天!

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