小编zen*_*ezz的帖子

使用opencv从图像中删除水印

首先,我有这个图像,我想制作一个应用程序,可以检测像它的图像,并从中删除圆(水印).

图像有水印

int main(){
    Mat im1,im2,im3,gray,gray2,result;

    im2=imread(" (2).jpg");
    namedWindow("x",CV_WINDOW_FREERATIO);
    imshow("x",im2);

    //converting it to gray
    cvtColor(im2,gray,CV_BGR2GRAY);
    // creating a new image that will have the cropped ellipse
    Mat ElipseImg(im2.rows,im2.cols,CV_8UC1,Scalar(0,0,0));

    //detecting the largest circle
    GaussianBlur(gray,gray,Size(5,5),0);
    vector<Vec3f> circles;
    HoughCircles(gray,circles,CV_HOUGH_GRADIENT,1,gray.rows/8,100,100,100,0);

    uchar x;
    int measure=0;int id=0;
    for(int i=0;i<circles.size();i++){
        if(cvRound(circles[i][2])>measure && cvRound(circles[i][2])<1000){
            measure=cvRound(circles[i][2]);
            id=i;
        }
    }


    Point center(cvRound(circles[id][0]),cvRound(circles[id][1]));
    int radius=cvRound(circles[id][2]);
    circle(im2,center,3,Scalar(0,255,0),-1,8,0);
    circle(im2,center,radius,Scalar(0,255,0),2,8,0);
    ellipse(ElipseImg,center,Size(radius,radius),0,0,360,Scalar(255,255,255),-1,8);
    cout<<"center: "<<center<<" radius: "<<radius<<endl;



    Mat res;
    bitwise_and(gray,ElipseImg,result);
    namedWindow("bitwise and",CV_WINDOW_FREERATIO);
    imshow("bitwise and",result);

    // trying to estimate the Intensity  of the circle for the thresholding
    x=result.at<uchar>(cvRound(circles[id][0]+30),cvRound(circles[id][1])); …
Run Code Online (Sandbox Code Playgroud)

c++ opencv watermark image-processing

51
推荐指数
2
解决办法
1万
查看次数

有效的C++:阻止受保护的继承?

我正在阅读Scott Meyers的Effective C++(第三版),在第32项的一段中:确保公共继承是第151页的"is-a",他发表了评论(我以粗体显示):

这仅适用于公共继承.只有当Student公开派生于Person时,C++才会表现得如我所描述的那样.私有继承意味着完全不同的东西(见第39项),受保护的继承是我今天的意义所在.

问题是:我该如何解释这个评论?迈耶斯试图传达受保护的遗产很少被认为是有用的,应该避免吗?

(我已经阅读了私有,公共和受保护的继承以及C++ FAQ Lite的私有和受保护的继承部分之间区别问题,这两个部分都解释了受保护的继承意味着什么,但是没有让我深入了解何时或为什么它会有用.)

c++ inheritance effective-c++

22
推荐指数
2
解决办法
3697
查看次数

是std :: find和std :: map.find都是O(logN)?

std::findstd::map.findO(logN)?如果是,那么如何在对数时间内std::find实现搜索std::map

是否std::find专门针对std::map用例实施?

c++ stl

6
推荐指数
1
解决办法
570
查看次数

TCP 套接字是否安全还是我应该始终检查用户

我有一个 C++ 应用程序,它通过 TCP 套接字连接到 nodeJS 服务器。在套接字“握手”上,客户端使用服务器已知的 UUID 对自身进行身份验证,然后服务器将帐户关联到此识别的 UUID

一旦 TCP 套接字打开,应用程序发送请求,服务器通过同一个套接字应答。

是否有必要为每个请求添加密码以确保请求来自客户端?或者插座应该就位并保持在原位?

所以我应该确定客户是客户:

  • 只有在打开插座时?
  • 每次提出请求?

c++ sockets ssl tcp node.js

2
推荐指数
1
解决办法
1641
查看次数

为什么向量内的结构中的布尔值没有被更新?

这可能听起来像一个非常基本的问题,但我现在试图修复一个简单的错误超过一个小时,我似乎无法理解发生了什么.

我的头文件中有以下结构声明:

struct StudentBody
{
    string name;

    Vec2 position;

    bool disabled;

    StudentBody(string name, Vec2 position) : name(name), position(position) {}
};
Run Code Online (Sandbox Code Playgroud)

这个结构被填充到一个类型的向量中:

std::vector<StudentBody> students_real;
Run Code Online (Sandbox Code Playgroud)

像这样:

students_real =
    {
        StudentBody("student1",Vec2(DISPLAY_WIDTH - 50, LOWER_MARGIN + 100)),
        StudentBody("student2",Vec2(DISPLAY_WIDTH - 100, LOWER_MARGIN + 100)),
        StudentBody("student3",Vec2(DISPLAY_WIDTH - 150, LOWER_MARGIN + 100)),
        StudentBody("student4",Vec2(DISPLAY_WIDTH - 200, LOWER_MARGIN + 100))
    };
Run Code Online (Sandbox Code Playgroud)

默认情况下,所有学生都将其"禁用"设置为false.

然后我有一个"更新"方法,用屏幕刷新率触发,在该方法中我有以下代码:

for (auto it = students_real.begin(); it != students_real.end(); it++)
        {
            auto student_to_check = *it;

            CCLOG("student %s disabled -> %i",student_to_check.name.c_str(),student_to_check.disabled);

            if (student_to_check.name == "student1" || student_to_check.disabled) { …
Run Code Online (Sandbox Code Playgroud)

c++ c++11

0
推荐指数
1
解决办法
111
查看次数