这是我在图像中创建hough accumulator
for 行的代码:
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) 我想使用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)