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

本站现有博文321篇,共被浏览775669

本站已经建立2466天!

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