我是靠谱客的博主 殷勤苗条,最近开发中收集的这篇文章主要介绍在图像上画矩形 opencv,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

IplImage * c_allImage =cvCloneImage(image);

         cv::Matmtx(c_allImage, 0);

//画矩形的上面的边,宽度为5

         for(int j = origin_upToup; j < origin_upToup + 5; j++)

                   for(inti = origin_leftToleft; i < origin_leftToleft + origin_width; i++)

                             for(int n = 0;n < mtx.channels(); n++){

                                     if(n == 0) mtx.at<uchar>(origin_upToup,i * mtx.channels() + n) = 255;   //取得像素或者赋值

                                     else

                                               mtx.at<uchar>(j,i* mtx.channels() + n) = 0;

                            }

//画矩形的下面的边,宽度为5

         for(int j = origin_upToup; j < origin_upToup + 5; j++)

                   for(inti = origin_leftToleft; i < origin_leftToleft + origin_width; i++)

                             for(int n = 0; n < mtx.channels(); n++){

                                      if (n == 0)mtx.at<uchar>(origin_upToup,i * mtx.channels() + n) = 255;   //取得像素或者赋值

                                      else

                                                mtx.at<uchar>((j + origin_height),i *mtx.channels() + n) = 0;

                            }

//画矩形的左面的边,宽度为5

         for(int j = origin_leftToleft; j < origin_leftToleft + 5; j++)

                   for(inti = origin_upToup; i < origin_upToup + origin_height; i++)

                             for(int n = 0; n < mtx.channels(); n++){

                                      if (n == 0) mtx.at<uchar>(i,origin_leftToleft* mtx.channels() + n) = 255;   //取得像素或者赋值

                                      else

                                                mtx.at<uchar>(i,j * mtx.channels() + n)= 0;

                            }

//画矩形的右面的边,宽度为5

         for(int j = origin_leftToleft; j > origin_leftToleft - 5; j--)

                   for(inti = origin_upToup; i < origin_upToup + origin_height; i++)

                             for(int n = 0; n < mtx.channels(); n++){

                                      if (n == 0)mtx.at<uchar>(i,(origin_leftToleft + origin_width) * mtx.channels() + n)= 255;   //取得像素或者赋值

                                      else

                                                mtx.at<uchar>(i,(j + origin_width) *mtx.channels() + n) = 0;

                            }

         *c_allImage= IplImage(mtx);

最后

以上就是殷勤苗条为你收集整理的在图像上画矩形 opencv的全部内容,希望文章能够帮你解决在图像上画矩形 opencv所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(44)

评论列表共有 0 条评论

立即
投稿
返回
顶部