小编dar*_*der的帖子

霍夫变换中的负 rho 值如何处理?

这是我在图像中创建hough accumulatorfor 行的代码:

\n\n
void hough_lines_acc(cv::Mat img_a_edges, std::vector<std::vector<int> > &hough_acc) {\n  for (size_t r = 0; r < img_a_edges.rows; r++) {\n    for (size_t c = 0; c < img_a_edges.cols; c++) {\n      int theta = static_cast<int> (std::atan2(r, c) * 180 / M_PI);\n      int rho = static_cast<int> ((c * cos(theta)) + (r * sin(theta)));\n      if (theta < -90) theta = -90;\n      if (theta > 89) theta = 89;\n\n      ++hough_acc[abs(rho)][theta];\n    }\n  }\n\n  cv::Mat img_mat(hough_acc.size(), hough_acc[0].size(), CV_8U);\n\n  std::cout << hough_acc.size() << " …
Run Code Online (Sandbox Code Playgroud)

c++ opencv computer-vision

5
推荐指数
1
解决办法
2133
查看次数

有文本输出的protobuf示例吗?

我想使用protobuf并以文本格式创建序列化输出文件,以进行测试和替换json。我不知道如何独自编写它,并且正在寻找示例。这是一个二进制输出:

#include <iostream>
#include <fstream>
#include <string>
#include "addressbook.pb.h"
using namespace std;

// This function fills in a Person message based on user input.
void PromptForAddress(tutorial::Person* person) {
  cout << "Enter person ID number: ";
  int id;
  cin >> id;
  person->set_id(id);
  cin.ignore(256, '\n');

  cout << "Enter name: ";
  getline(cin, *person->mutable_name());

  cout << "Enter email address (blank for none): ";
  string email;
  getline(cin, email);
  if (!email.empty()) {
    person->set_email(email);
  }

  while (true) {
    cout << "Enter a phone number (or leave blank …
Run Code Online (Sandbox Code Playgroud)

c++ protocol-buffers

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

标签 统计

c++ ×2

computer-vision ×1

opencv ×1

protocol-buffers ×1