使用boost::sub_range进行迭代器范围的测试

204 篇文章 ¥99.90 ¥299.90
在C++中,boost::sub_range库提供了一种方便的方式来操作容器内的特定数据段,增强代码可读性和可维护性。通过实例展示了如何创建并使用boost::sub_range来选取和打印向量的部分元素,从而验证其功能。

使用boost::sub_range进行迭代器范围的测试

在C++中,我们经常需要对容器中的某一段数据进行操作,比如排序、查找等。然而,如果每次都手动指定迭代器范围,可能会显得很繁琐。这时候,就需要使用迭代器范围库来简化代码。

boost::sub_range是一个非常好用的迭代器范围库,它可以让我们非常方便地操作容器中的某一段数据,同时还保证了代码的可读性和可维护性。接下来,我会展示一个基于boost::sub_range的测试程序。

首先,我们需要安装boost库,然后我们可以使用下面的代码测试是否安装成功:

#include <boost/version.hpp>
#include <iostream>

int main
请仔细阅读和分析下面函数,进行优化后,采用C/C++11标准,完整推导并重构可编译的全部代码 要求如下: 1.保持所有原始功能不变,不要遗漏逻辑细节 2.提高执行效率,降低计算复杂度 3.已经给定的结构体名字和元素不要更改,详细的中文注释 4.自动添加中文注释说明功能逻辑 5.不使用 auto,使用显式 for 循环 6.结构体采用32位定义 7.不要使用小函数,保持原始的函数定义 8.严格保持protobuf字段映射关系 特别注意: 1.函数中有关位操作不变,函数间的位操作一致 2.函数中的 HDDMXng::BelUsageAttrib::BelUsageAttrib 映射为 message BelUsageAttrib { optional uint32 flags = 1; optional uint32 type = 2; optional uint32 bitwidth = 3; optional string attribname = 4; optional sint32 defint = 5; optional double defdouble = 6; optional bool defbool = 7; optional string defstring = 8; repeated sint32 listofints = 9 [packed = true]; repeated double listofdoubles = 10 [packed = true]; repeated bool listofbools = 11 [packed = true]; repeated string listofstrings = 12; optional uint32 precision = 13; } 3.采用 google::protobuf::Descriptor 和 google::protobuf::Reflection 进行编程 将函数中的 _BYTE attrib_msg[24] 映射为 HDDMXng::BelUsageAttrib attrib_msg 仔细解析 _BYTE attrib_msg[24] 所有字段 void __fastcall HDDMBelUsageAttrib::readme_pb(HDDMBelUsageAttrib *this, std::istream *stream, HDDMDevice *hddmDevice) { google::protobuf::Message *v4; // rdx unsigned int v5; // ecx bool v6; // zf _QWORD *v7; // r12 _QWORD *qword30_1; // rbp unsigned __int64 v9; // r15 _QWORD *qword28_8; // r13 __int64 v11; // rbp __int64 v12; // rax __int64 v13; // rcx __int64 v14; // rdi unsigned __int64 v15; // rdx int v16; // esi __int64 v17; // rsi __int64 v18; // rcx int v19; // r8d int v20; // r9d void *n_23; // r14 char *s2_4; // rbp __int64 qword48_3; // r13 char *p_char40_6; // r15 int v25; // eax unsigned __int64 n_24; // r12 size_t n_9; // rdx __int64 n0x7FFFFFFF_3; // r12 unsigned __int64 n_25; // rcx size_t n_10; // rdx int v31; // eax __int64 p_char40_7; // rax int v33; // eax __int64 *qword28_9; // rax unsigned __int64 v35; // rdx unsigned __int64 v36; // rsi __int64 v37; // r12 __int64 qword28_10; // rax __int64 qword28_6; // r13 unsigned __int64 n_6; // r14 char *s_2; // rbp __int64 qword48_6; // r8 signed __int64 v43; // r9 __int64 v44; // rax char *v45; // r15 __int64 v46; // r12 int v47; // edi char v48; // si __int64 *v49; // rdi __int64 v50; // rax __int64 v51; // rax void *n_19; // r13 __int64 *s2_3; // rbp __int64 qword48_2; // r14 char *p_char40_4; // r15 int v56; // eax unsigned __int64 n_20; // r12 size_t n_7; // rdx __int64 n0x7FFFFFFF_2; // r12 unsigned __int64 n_21; // rcx size_t n_8; // rdx int v62; // eax __int64 p_char40_5; // rax int v64; // r13d char **qword28_7; // rax unsigned __int64 v66; // rdx unsigned __int64 v67; // rsi unsigned __int64 v68; // r13 _QWORD *qword28_5; // rax _QWORD *qword28_3; // r12 unsigned __int64 n_3; // r13 char *s_1; // rax char *v73; // r14 char *s_4; // rbp signed __int64 v75; // r9 __int64 qword48_5; // r8 void *n_15; // r14 __int64 *s2_2; // rbp __int64 qword48_1; // r13 char *p_char40_2; // r15 int v81; // eax unsigned __int64 n_16; // r12 size_t n_4; // rdx __int64 n0x7FFFFFFF_1; // r12 unsigned __int64 n_17; // rcx size_t n_5; // rdx int v87; // eax __int64 p_char40_3; // rax char **qword28_4; // rax unsigned __int64 v90; // rdx unsigned __int64 v91; // rsi unsigned __int64 v92; // r13 _QWORD *qword28_1; // rax _QWORD *qword28_2; // r12 unsigned __int64 n; // r13 char *s; // rax char *v97; // r14 char *s_3; // rbp __int64 qword48; // r8 signed __int64 v100; // r9 __int64 v101; // rcx void *n_11; // r14 __int64 *s2_1; // rbp __int64 qword48_4; // r13 char *p_char40; // r15 int v106; // eax unsigned __int64 n_12; // r12 size_t n_1; // rdx __int64 n0x7FFFFFFF; // r12 unsigned __int64 n_13; // rcx size_t n_2; // rdx int v112; // eax __int64 p_char40_1; // rax char **qword28; // rax unsigned __int64 v115; // rdx unsigned __int64 v116; // rsi signed __int64 v117; // r9 int v118; // eax int v119; // ecx int v120; // edx unsigned __int64 v121; // [rsp+0h] [rbp-1E8h] unsigned __int64 v122; // [rsp+0h] [rbp-1E8h] int v123; // [rsp+0h] [rbp-1E8h] int v124; // [rsp+0h] [rbp-1E8h] unsigned __int64 v125; // [rsp+8h] [rbp-1E0h] unsigned __int64 v126; // [rsp+8h] [rbp-1E0h] unsigned __int64 n_26; // [rsp+20h] [rbp-1C8h] unsigned __int64 n_22; // [rsp+20h] [rbp-1C8h] unsigned __int64 n_18; // [rsp+20h] [rbp-1C8h] unsigned __int64 n_14; // [rsp+20h] [rbp-1C8h] void **s1_1; // [rsp+40h] [rbp-1A8h] BYREF void **s1_2; // [rsp+50h] [rbp-198h] BYREF void **s1_3; // [rsp+60h] [rbp-188h] BYREF void **s2_5; // [rsp+70h] [rbp-178h] BYREF void *s1_4[2]; // [rsp+80h] [rbp-168h] BYREF __int64 v136; // [rsp+90h] [rbp-158h] BYREF void *s1_5[2]; // [rsp+A0h] [rbp-148h] BYREF __int64 v138; // [rsp+B0h] [rbp-138h] BYREF void *s1[2]; // [rsp+C0h] [rbp-128h] BYREF __int64 v140; // [rsp+D0h] [rbp-118h] BYREF void *s2[2]; // [rsp+E0h] [rbp-108h] BYREF char v142; // [rsp+F0h] [rbp-F8h] BYREF _BYTE attrib_msg[24]; // [rsp+100h] [rbp-E8h] BYREF int v144; // [rsp+118h] [rbp-D0h] __int64 v145; // [rsp+120h] [rbp-C8h] int v146; // [rsp+130h] [rbp-B8h] __int64 v147; // [rsp+138h] [rbp-B0h] int v148; // [rsp+148h] [rbp-A0h] __int64 v149; // [rsp+150h] [rbp-98h] int v150; // [rsp+168h] [rbp-80h] __int64 v151; // [rsp+170h] [rbp-78h] __int64 v152; // [rsp+178h] [rbp-70h] _QWORD *v153; // [rsp+180h] [rbp-68h] unsigned int v154; // [rsp+188h] [rbp-60h] char v155; // [rsp+18Ch] [rbp-5Ch] __int16 v156; // [rsp+190h] [rbp-58h] int v157; // [rsp+194h] [rbp-54h] __int64 qword30; // [rsp+198h] [rbp-50h] char v159; // [rsp+1A0h] [rbp-48h] char v160; // [rsp+1A4h] [rbp-44h] if ( HDDMDeviceDump::useXngMarks ) std::istream::read(stream, HDDMDeviceDump::markBuffer, 14); HDDMXng::BelUsageAttrib::BelUsageAttrib((HDDMXng::BelUsageAttrib *)attrib_msg); HDDMDevice::readMessage((HDDMDevice *)stream, (std::istream *)attrib_msg, v4); v5 = (4 * ((v154 >> 3) & 1)) | (2 * ((v154 >> 2) & 1)) & 0xFFFFFFBB | ((v154 & 2) != 0) | HIBYTE(this->attrib_flags) & 0xB8 | (((v154 >> 4) & 1) << 6); BYTE1(this->attrib_type) = ((unsigned __int8)(v154 >> 7) << 7) | (((v154 & 0x40) != 0) << 6) & 0x7F | (32 * ((v154 & 0x20) != 0)) & 0x7F | BYTE1(this->attrib_type) & 0x1F; v6 = (attrib_msg[16] & 0x10) == 0; HIBYTE(this->attrib_flags) = (8 * (v155 & 7)) | v5 & 0xC7; if ( !v6 ) LOWORD(this->attrib_flags) = v156 & 0xFFF | this->attrib_flags & 0xF000; std::string::_M_assign(&this->attrib_name, v152); switch ( (HIBYTE(this->attrib_flags) >> 3) & 7 ) { case 1: v92 = v144; qword28_1 = (_QWORD *)operator new(0x18u); qword28_2 = qword28_1; *qword28_1 = 0; qword28_1[1] = 0; qword28_1[2] = 0; if ( !v92 ) { v119 = v144; qword28_1[2] = 0; qword28_1[1] = 0; this->qword28 = qword28_1; if ( v119 <= 0 ) goto LABEL_158; goto LABEL_163; } if ( v92 > 0x3FFFFFFFFFFFFFFFLL ) std::__throw_bad_alloc(); n = 4 * v92; s = (char *)operator new(n); v97 = &s[n]; *qword28_2 = s; s_3 = s; qword28_2[2] = &s[n]; memset(s, 0, n); LODWORD(v100) = v144; qword28_2[1] = v97; this->qword28 = qword28_2; if ( (int)v100 <= 0 ) goto LABEL_158; if ( !n ) { LABEL_163: v116 = 0; v115 = 0; LABEL_164: std::__throw_out_of_range_fmt( "vector::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)", v116, v115); } v126 = 0; v101 = 0; v124 = 0; while ( 2 ) { *(_DWORD *)&s_3[4 * v101] = *(_DWORD *)(v145 + 4LL * v124 + 8); HDDMBelUsageAttrib::getValueAsString[abi:cxx11]((__int64)s1_4, this, v124, v101, qword48, v100); qword48 = this->qword48; if ( !qword48 ) { p_char40 = (char *)&this->qword40; goto LABEL_149; } n_11 = s1_4[1]; s2_1 = (__int64 *)s1_4[0]; qword48_4 = this->qword48; p_char40 = (char *)&this->qword40; do { while ( 1 ) { n_12 = *(_QWORD *)(qword48_4 + 40); n_1 = (size_t)n_11; if ( n_12 <= (unsigned __int64)n_11 ) n_1 = *(_QWORD *)(qword48_4 + 40); if ( !n_1 ) break; v106 = memcmp(*(const void **)(qword48_4 + 32), s2_1, n_1); if ( !v106 ) break; if ( v106 < 0 ) goto LABEL_122; LABEL_115: p_char40 = (char *)qword48_4; qword48_4 = *(_QWORD *)(qword48_4 + 16); if ( !qword48_4 ) goto LABEL_123; } n0x7FFFFFFF = n_12 - (_QWORD)n_11; if ( n0x7FFFFFFF > 0x7FFFFFFF || n0x7FFFFFFF >= (__int64)0xFFFFFFFF80000000LL && (int)n0x7FFFFFFF >= 0 ) goto LABEL_115; LABEL_122: qword48_4 = *(_QWORD *)(qword48_4 + 24); } while ( qword48_4 ); LABEL_123: if ( p_char40 == (char *)&this->qword40 ) goto LABEL_149; n_13 = *((_QWORD *)p_char40 + 5); n_2 = (size_t)n_11; if ( n_13 <= (unsigned __int64)n_11 ) n_2 = *((_QWORD *)p_char40 + 5); if ( n_2 && (n_14 = *((_QWORD *)p_char40 + 5), v112 = memcmp(s2_1, *((const void **)p_char40 + 4), n_2), n_13 = n_14, v112) ) { if ( v112 >= 0 ) goto LABEL_129; LABEL_149: s1_1 = s1_4; p_char40_1 = sub_F187E0(&this->qword38, p_char40, &s1_1); s2_1 = (__int64 *)s1_4[0]; } else { p_char40_1 = (__int64)p_char40; v100 = (signed __int64)n_11 - n_13; if ( (__int64)((__int64)n_11 - n_13) <= 0x7FFFFFFF ) { if ( v100 < (__int64)0xFFFFFFFF80000000LL || (int)v100 < 0 ) goto LABEL_149; LABEL_129: p_char40_1 = (__int64)p_char40; } } *(_WORD *)(p_char40_1 + 64) = v124; if ( s2_1 != &v136 ) operator delete(s2_1); if ( ++v124 < v144 ) { qword28 = (char **)this->qword28; v101 = ++v126; s_3 = *qword28; v115 = (qword28[1] - *qword28) >> 2; if ( v115 <= v126 ) { v116 = v126; goto LABEL_164; } continue; } break; } LABEL_158: LODWORD(this->qword30) = v157; LABEL_7: if ( (attrib_msg[17] & 1) != 0 ) BYTE1(this->attrib_type) = (4 * (v160 & 7)) | BYTE1(this->attrib_type) & 0xE3 | 2; HDDMXng::BelUsageAttrib::~BelUsageAttrib((HDDMXng::BelUsageAttrib *)attrib_msg); return; case 2: v68 = v146; qword28_5 = (_QWORD *)operator new(0x18u); qword28_3 = qword28_5; *qword28_5 = 0; qword28_5[1] = 0; qword28_5[2] = 0; if ( v68 ) { if ( v68 > 0x1FFFFFFFFFFFFFFFLL ) std::__throw_bad_alloc(); n_3 = 8 * v68; s_1 = (char *)operator new(n_3); v73 = &s_1[n_3]; *qword28_3 = s_1; s_4 = s_1; qword28_3[2] = &s_1[n_3]; memset(s_1, 0, n_3); LODWORD(qword48_5) = v146; qword28_3[1] = v73; this->qword28 = qword28_3; if ( (int)qword48_5 > 0 ) { v125 = 0; if ( n_3 ) { v123 = 0; while ( 1 ) { *(_QWORD *)&s_4[8 * v125] = *(_QWORD *)(v147 + 8LL * v123 + 8); HDDMBelUsageAttrib::getValueAsString[abi:cxx11]( (__int64)s1_5, this, v123, (unsigned int)v123, qword48_5, v75); qword48_5 = this->qword48; if ( !qword48_5 ) { p_char40_2 = (char *)&this->qword40; goto LABEL_153; } n_15 = s1_5[1]; s2_2 = (__int64 *)s1_5[0]; qword48_1 = this->qword48; p_char40_2 = (char *)&this->qword40; do { while ( 1 ) { n_16 = *(_QWORD *)(qword48_1 + 40); n_4 = (size_t)n_15; if ( n_16 <= (unsigned __int64)n_15 ) n_4 = *(_QWORD *)(qword48_1 + 40); if ( !n_4 ) break; v81 = memcmp(*(const void **)(qword48_1 + 32), s2_2, n_4); if ( !v81 ) break; if ( v81 < 0 ) goto LABEL_93; LABEL_86: p_char40_2 = (char *)qword48_1; qword48_1 = *(_QWORD *)(qword48_1 + 16); if ( !qword48_1 ) goto LABEL_94; } n0x7FFFFFFF_1 = n_16 - (_QWORD)n_15; if ( n0x7FFFFFFF_1 > 0x7FFFFFFF || n0x7FFFFFFF_1 >= (__int64)0xFFFFFFFF80000000LL && (int)n0x7FFFFFFF_1 >= 0 ) { goto LABEL_86; } LABEL_93: qword48_1 = *(_QWORD *)(qword48_1 + 24); } while ( qword48_1 ); LABEL_94: if ( p_char40_2 == (char *)&this->qword40 ) goto LABEL_153; n_17 = *((_QWORD *)p_char40_2 + 5); n_5 = (size_t)n_15; if ( n_17 <= (unsigned __int64)n_15 ) n_5 = *((_QWORD *)p_char40_2 + 5); if ( n_5 && (n_18 = *((_QWORD *)p_char40_2 + 5), v87 = memcmp(s2_2, *((const void **)p_char40_2 + 4), n_5), n_17 = n_18, v87) ) { if ( v87 >= 0 ) goto LABEL_100; LABEL_153: s1_2 = s1_5; p_char40_3 = sub_F187E0(&this->qword38, p_char40_2, &s1_2); s2_2 = (__int64 *)s1_5[0]; } else { p_char40_3 = (__int64)p_char40_2; v75 = (signed __int64)n_15 - n_17; if ( (__int64)((__int64)n_15 - n_17) <= 0x7FFFFFFF ) { if ( v75 < (__int64)0xFFFFFFFF80000000LL || (int)v75 < 0 ) goto LABEL_153; LABEL_100: p_char40_3 = (__int64)p_char40_2; } } *(_WORD *)(p_char40_3 + 64) = v123; if ( s2_2 != &v138 ) operator delete(s2_2); if ( v146 <= ++v123 ) goto LABEL_157; qword28_4 = (char **)this->qword28; ++v125; s_4 = *qword28_4; v90 = (qword28_4[1] - *qword28_4) >> 3; if ( v90 <= v125 ) { v91 = v125; goto LABEL_167; } } } LABEL_166: v91 = 0; v90 = 0; LABEL_167: std::__throw_out_of_range_fmt( "vector::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)", v91, v90); } } else { v120 = v146; qword28_5[2] = 0; qword28_5[1] = 0; this->qword28 = qword28_5; if ( v120 > 0 ) goto LABEL_166; } LABEL_157: this->qword30 = qword30; goto LABEL_7; case 3: v37 = v148; qword28_10 = operator new(0x28u); *(_QWORD *)qword28_10 = 0; *(_DWORD *)(qword28_10 + 8) = 0; *(_QWORD *)(qword28_10 + 16) = 0; *(_DWORD *)(qword28_10 + 24) = 0; qword28_6 = qword28_10; *(_QWORD *)(qword28_10 + 32) = 0; n_6 = 8 * ((unsigned __int64)(v37 + 63) >> 6); s_2 = (char *)operator new(n_6); *(_QWORD *)qword28_6 = s_2; v44 = v37 + 63; *(_DWORD *)(qword28_6 + 8) = 0; *(_QWORD *)(qword28_6 + 32) = &s_2[n_6]; if ( v37 >= 0 ) v44 = v37; v45 = &s_2[8 * (v44 >> 6)]; v46 = v37 % 64; if ( v46 < 0 ) { v46 += 64; v45 -= 8; } *(_QWORD *)(qword28_6 + 16) = v45; *(_DWORD *)(qword28_6 + 24) = v46; if ( s_2 != &s_2[n_6] ) memset(s_2, 0, n_6); v47 = v148; this->qword28 = qword28_6; if ( v47 <= 0 ) goto LABEL_141; v48 = *(_BYTE *)(v149 + 8); if ( !(v46 + 8 * (v45 - s_2)) ) { v67 = 0; v66 = 0; LABEL_172: std::__throw_out_of_range_fmt( "vector<bool>::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)", v67, v66); } v122 = 0; LABEL_51: v49 = (__int64 *)&s_2[8 * (v122 >> 6)]; v50 = 1LL << v122; if ( v48 ) v51 = *v49 | v50; else v51 = *v49 & ~v50; *v49 = v51; HDDMBelUsageAttrib::getValueAsString[abi:cxx11]((__int64)s1, this, v122, v122, qword48_6, v43); qword48_6 = this->qword48; if ( !qword48_6 ) { p_char40_4 = (char *)&this->qword40; goto LABEL_138; } n_19 = s1[1]; s2_3 = (__int64 *)s1[0]; qword48_2 = this->qword48; p_char40_4 = (char *)&this->qword40; while ( 1 ) { while ( 1 ) { n_20 = *(_QWORD *)(qword48_2 + 40); n_7 = (size_t)n_19; if ( n_20 <= (unsigned __int64)n_19 ) n_7 = *(_QWORD *)(qword48_2 + 40); if ( n_7 ) { v56 = memcmp(*(const void **)(qword48_2 + 32), s2_3, n_7); if ( v56 ) break; } n0x7FFFFFFF_2 = n_20 - (_QWORD)n_19; if ( n0x7FFFFFFF_2 > 0x7FFFFFFF || n0x7FFFFFFF_2 >= (__int64)0xFFFFFFFF80000000LL && (int)n0x7FFFFFFF_2 >= 0 ) goto LABEL_57; LABEL_64: qword48_2 = *(_QWORD *)(qword48_2 + 24); if ( !qword48_2 ) { LABEL_65: if ( &this->qword40 == (_QWORD *)p_char40_4 ) goto LABEL_138; n_21 = *((_QWORD *)p_char40_4 + 5); n_8 = (size_t)n_19; if ( n_21 <= (unsigned __int64)n_19 ) n_8 = *((_QWORD *)p_char40_4 + 5); if ( n_8 && (n_22 = *((_QWORD *)p_char40_4 + 5), v62 = memcmp(s2_3, *((const void **)p_char40_4 + 4), n_8), n_21 = n_22, v62) ) { if ( v62 >= 0 ) goto LABEL_71; LABEL_138: s1_3 = s1; p_char40_5 = sub_F187E0(&this->qword38, p_char40_4, &s1_3); s2_3 = (__int64 *)s1[0]; } else { p_char40_5 = (__int64)p_char40_4; v43 = (signed __int64)n_19 - n_21; if ( (__int64)((__int64)n_19 - n_21) <= 0x7FFFFFFF ) { if ( v43 < (__int64)0xFFFFFFFF80000000LL || (int)v43 < 0 ) goto LABEL_138; LABEL_71: p_char40_5 = (__int64)p_char40_4; } } *(_WORD *)(p_char40_5 + 64) = v122; if ( s2_3 != &v140 ) operator delete(s2_3); v64 = v122 + 1; if ( v148 <= (int)v122 + 1 ) { LABEL_141: LOBYTE(this->qword30) = v159; goto LABEL_7; } ++v122; v48 = *(_BYTE *)(v149 + v64 + 8); qword28_7 = (char **)this->qword28; s_2 = *qword28_7; v66 = *((unsigned int *)qword28_7 + 6) + 8 * (qword28_7[2] - *qword28_7) - *((unsigned int *)qword28_7 + 2); if ( v122 >= v66 ) { v67 = v122; goto LABEL_172; } goto LABEL_51; } } if ( v56 < 0 ) goto LABEL_64; LABEL_57: p_char40_4 = (char *)qword48_2; qword48_2 = *(_QWORD *)(qword48_2 + 16); if ( !qword48_2 ) goto LABEL_65; } case 4: case 5: case 6: v9 = v150; v121 = v150; qword28_8 = (_QWORD *)operator new(0x18u); *qword28_8 = 0; qword28_8[1] = 0; qword28_8[2] = 0; if ( v9 ) { if ( v9 > 0x7FFFFFFFFFFFFFFLL ) std::__throw_bad_alloc(); v11 = 32 * v121; v12 = operator new(32 * v121); v13 = v12 + 32 * v121; v14 = v12; *qword28_8 = v12; qword28_8[1] = v12; v15 = v121; qword28_8[2] = v13; do { if ( v12 ) { *(_QWORD *)(v12 + 8) = 0; *(_BYTE *)(v12 + 16) = 0; *(_QWORD *)v12 = v12 + 16; } v12 += 32; --v15; } while ( v15 ); v16 = v150; v121 = 0; qword28_8[1] = v13; this->qword28 = qword28_8; if ( v16 > 0 ) { v17 = *(_QWORD *)(v151 + 8); if ( v11 ) { while ( 1 ) { std::string::_M_assign(32 * v121 + v14, v17); HDDMBelUsageAttrib::getValueAsString[abi:cxx11]((__int64)s2, this, v121, v18, v19, v20); if ( !this->qword48 ) { p_char40_6 = (char *)&this->qword40; goto LABEL_145; } n_23 = s2[1]; s2_4 = (char *)s2[0]; qword48_3 = this->qword48; p_char40_6 = (char *)&this->qword40; do { while ( 1 ) { n_24 = *(_QWORD *)(qword48_3 + 40); n_9 = (size_t)n_23; if ( n_24 <= (unsigned __int64)n_23 ) n_9 = *(_QWORD *)(qword48_3 + 40); if ( !n_9 ) break; v25 = memcmp(*(const void **)(qword48_3 + 32), s2_4, n_9); if ( !v25 ) break; if ( v25 < 0 ) goto LABEL_29; LABEL_22: p_char40_6 = (char *)qword48_3; qword48_3 = *(_QWORD *)(qword48_3 + 16); if ( !qword48_3 ) goto LABEL_30; } n0x7FFFFFFF_3 = n_24 - (_QWORD)n_23; if ( n0x7FFFFFFF_3 > 0x7FFFFFFF || n0x7FFFFFFF_3 >= (__int64)0xFFFFFFFF80000000LL && (int)n0x7FFFFFFF_3 >= 0 ) { goto LABEL_22; } LABEL_29: qword48_3 = *(_QWORD *)(qword48_3 + 24); } while ( qword48_3 ); LABEL_30: if ( p_char40_6 == (char *)&this->qword40 ) goto LABEL_145; n_25 = *((_QWORD *)p_char40_6 + 5); n_10 = (size_t)n_23; if ( n_25 <= (unsigned __int64)n_23 ) n_10 = *((_QWORD *)p_char40_6 + 5); if ( n_10 && (n_26 = *((_QWORD *)p_char40_6 + 5), v31 = memcmp(s2_4, *((const void **)p_char40_6 + 4), n_10), n_25 = n_26, v31) ) { if ( v31 >= 0 ) goto LABEL_36; LABEL_145: s2_5 = s2; p_char40_7 = sub_F187E0(&this->qword38, p_char40_6, &s2_5); s2_4 = (char *)s2[0]; } else { p_char40_7 = (__int64)p_char40_6; v117 = (signed __int64)n_23 - n_25; if ( (__int64)((__int64)n_23 - n_25) <= 0x7FFFFFFF ) { if ( v117 < (__int64)0xFFFFFFFF80000000LL || (int)v117 < 0 ) goto LABEL_145; LABEL_36: p_char40_7 = (__int64)p_char40_6; } } *(_WORD *)(p_char40_7 + 64) = v121; if ( s2_4 != &v142 ) operator delete(s2_4); v33 = v121 + 1; if ( v150 <= (int)v121 + 1 ) goto LABEL_6; ++v121; v17 = *(_QWORD *)(v151 + 8LL * v33 + 8); qword28_9 = (__int64 *)this->qword28; v14 = *qword28_9; v35 = (qword28_9[1] - *qword28_9) >> 5; if ( v35 <= v121 ) { v36 = v121; goto LABEL_161; } } } LABEL_160: v36 = v121; v35 = 0; LABEL_161: std::__throw_out_of_range_fmt( "vector::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)", v36, v35); } } else { v118 = v150; qword28_8[2] = 0; qword28_8[1] = 0; this->qword28 = qword28_8; if ( v118 > 0 ) goto LABEL_160; } LABEL_6: v7 = v153; qword30_1 = (_QWORD *)operator new(0x20u); *qword30_1 = qword30_1 + 2; sub_F12340(qword30_1, *v7, v7[1] + *v7); this->qword30 = qword30_1; goto LABEL_7; default: goto LABEL_7; } } 将函数中的 _BYTE attrib_msg[16] 映射为 HDDMXng::BelUsageAttrib attrib_msg void __fastcall HDDMBelUsageAttrib::writeme_pb(HDDMBelUsageAttrib *this, std::ostream *fileName) { unsigned __int8 attrib_code_high; // dl int v4; // eax int v5; // ecx int v6; // eax char v7; // cl int v8; // esi __int16 attrib_code; // ax int v10; // ecx unsigned __int16 v11; // ax _QWORD *p_attrib_name; // rsi const google::protobuf::Message *v13; // rdx __int64 qword30_2; // xmm0_8 unsigned __int8 v15; // al __int64 *qword28_6; // rax __int64 v17; // r12 __int64 v18; // rax __int64 v19; // r15 unsigned __int64 v20; // r13 int v21; // esi google::protobuf::Arena *v22; // r14 _QWORD *v23; // rax _QWORD *v24; // rbx _QWORD *v25; // rdi __int64 v26; // rax __int64 *qword28_7; // rax unsigned __int64 v28; // rdx _DWORD *v29; // rdx __int64 v30; // r12 __int64 v31; // rcx int v32; // eax __int64 *qword28_4; // rax __int64 v34; // rsi __int64 v35; // rcx __int64 v36; // r13 unsigned __int64 v37; // rbx __int64 *qword28_5; // rax unsigned __int64 v39; // rdx __int64 n4_21; // rax bool v41; // r12 _QWORD *v42; // r15 int n4_8; // edx google::protobuf::Arena *v44; // rdi int n4_7; // eax unsigned __int64 v46; // rdx size_t n; // rdx __int64 n4_12; // rcx __int64 *qword28_2; // rcx __int64 v50; // rax __int64 v51; // rcx __int64 v52; // r13 unsigned __int64 v53; // rbx __int64 *qword28_3; // rdx unsigned __int64 v55; // rdx __int64 v56; // xmm1_8 __int64 n4_19; // rax _QWORD *v58; // r14 int n4_4; // r12d google::protobuf::Arena *v60; // r15 unsigned __int64 v61; // rdx __int64 n4_18; // rax __int64 n4_6; // r15 __int64 *voidVec; // rcx __int64 v65; // rax __int64 v66; // rcx __int64 v67; // r14 unsigned __int64 v68; // rbx __int64 *qword28_1; // rdx unsigned __int64 v70; // rdx int v71; // r12d __int64 n4_16; // rax _QWORD *Aligned_1; // r15 int n4; // r13d google::protobuf::Arena *v75; // rdi unsigned __int64 v76; // rdx __int64 n4_15; // rax __int64 n4_2; // rcx char qword30_4; // al int voidVec1; // eax __int64 qword30_6; // rsi __int64 v82; // rax int n4_11; // eax _QWORD *v84; // rax google::protobuf::internal::RepeatedPtrFieldBase *v85; // [rsp+0h] [rbp-108h] int n4_13; // [rsp+0h] [rbp-108h] google::protobuf::internal::RepeatedPtrFieldBase *v87; // [rsp+0h] [rbp-108h] int n4_3; // [rsp+0h] [rbp-108h] int n4_9; // [rsp+1Ch] [rbp-ECh] _BYTE attrib_msg[16]; // [rsp+20h] [rbp-E8h] BYREF int v92; // [rsp+30h] [rbp-D8h] int n4_14; // [rsp+38h] [rbp-D0h] int n4_1; // [rsp+3Ch] [rbp-CCh] void *Aligned; // [rsp+40h] [rbp-C8h] int n4_17; // [rsp+50h] [rbp-B8h] int n4_5; // [rsp+54h] [rbp-B4h] void *v98; // [rsp+58h] [rbp-B0h] int n4_20; // [rsp+68h] [rbp-A0h] int n4_10; // [rsp+6Ch] [rbp-9Ch] void *v101; // [rsp+70h] [rbp-98h] google::protobuf::Arena *v102; // [rsp+80h] [rbp-88h] BYREF int v103; // [rsp+88h] [rbp-80h] int v104; // [rsp+8Ch] [rbp-7Ch] _DWORD *v105; // [rsp+90h] [rbp-78h] void *p__ZN6google8protobuf8internal26fixed_address_empty_stringB5cxx; // [rsp+98h] [rbp-70h] BYREF void *p__ZN6google8protobuf8internal26fixed_address_empty_stringB5cxx_1; // [rsp+A0h] [rbp-68h] BYREF int v108; // [rsp+A8h] [rbp-60h] int v109; // [rsp+ACh] [rbp-5Ch] int v110; // [rsp+B0h] [rbp-58h] int qword30_1; // [rsp+B4h] [rbp-54h] __int64 qword30_3; // [rsp+B8h] [rbp-50h] char qword30_5; // [rsp+C0h] [rbp-48h] int v114; // [rsp+C4h] [rbp-44h] if ( HDDMDeviceDump::useXngMarks ) std::ostream::write(fileName, "BELUSAGEATTRIB", 14); HDDMXng::BelUsageAttrib::BelUsageAttrib((HDDMXng::BelUsageAttrib *)attrib_msg); attrib_code_high = HIBYTE(this->attrib_flags); v4 = attrib_code_high & 1; v5 = (_BYTE)v4 == 0 ? 4 : 6; v6 = (v4 << 31 >> 31) & 2; if ( (attrib_code_high & 2) != 0 ) v6 = v5; if ( (attrib_code_high & 4) != 0 ) v6 |= 8u; if ( (attrib_code_high & 0x40) != 0 ) v6 |= 0x10u; v7 = BYTE1(this->attrib_type); if ( (v7 & 0x20) != 0 ) v6 |= 0x20u; if ( (v7 & 0x40) != 0 ) v6 |= 0x40u; v8 = v6; if ( v7 < 0 ) { LOBYTE(v8) = v6 | 0x80; v6 = v8; } v108 = v6; attrib_code = this->attrib_flags; v109 = (attrib_code_high >> 3) & 7; v10 = v92 | 0xC; v11 = attrib_code & 0xFFF; if ( v11 ) { v10 = v92 | 0x1C; v110 = v11; } p_attrib_name = &this->attrib_name; v92 = v10 | 1; if ( p__ZN6google8protobuf8internal26fixed_address_empty_stringB5cxx == &google::protobuf::internal::fixed_address_empty_string[abi:cxx11] ) sub_E76770(&p__ZN6google8protobuf8internal26fixed_address_empty_stringB5cxx, p_attrib_name); else std::string::_M_assign(p__ZN6google8protobuf8internal26fixed_address_empty_stringB5cxx, p_attrib_name); v13 = (const google::protobuf::Message *)HIBYTE(this->attrib_flags); switch ( (HIBYTE(this->attrib_flags) >> 3) & 7 ) { case 1: voidVec = (__int64 *)this->qword28; if ( !voidVec ) goto LABEL_102; v65 = *voidVec; v66 = (voidVec[1] - *voidVec) >> 2; if ( (int)v66 <= 0 ) goto LABEL_102; if ( !v66 ) { v70 = 0; v68 = 0; LABEL_140: std::__throw_out_of_range_fmt( "vector::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)", v68, v70); } v67 = (unsigned int)(v66 - 1); v68 = 0; while ( 2 ) { v71 = *(_DWORD *)(v65 + 4 * v68); n4_16 = n4_14; if ( n4_14 != n4_1 ) goto LABEL_83; Aligned_1 = Aligned; n4 = n4_14 + 1; if ( Aligned ) { v75 = *(google::protobuf::Arena **)Aligned; if ( 2 * n4_14 >= n4 ) n4 = 2 * n4_14; v87 = *(google::protobuf::internal::RepeatedPtrFieldBase **)Aligned; if ( n4 < 4 ) n4 = 4; v76 = 4LL * n4 + 8; if ( v75 ) { Aligned = (void *)google::protobuf::Arena::AllocateAligned(v75, (const type_info *)&`typeinfo for'char, v76); *(_QWORD *)Aligned = v87; n4_15 = n4_14; n4_2 = n4_1; n4_1 = n4; if ( n4_14 <= 0 ) goto LABEL_95; goto LABEL_93; } } else { if ( 2 * n4_14 >= n4 ) n4 = 2 * n4_14; if ( n4 < 4 ) n4 = 4; v76 = 4LL * n4 + 8; } Aligned = (void *)operator new(v76); *(_QWORD *)Aligned = 0; n4_15 = n4_14; n4_2 = n4_1; n4_1 = n4; if ( n4_14 > 0 ) { LABEL_93: n4_3 = n4_2; memcpy((char *)Aligned + 8, Aligned_1 + 1, 4 * n4_15); n4_2 = n4_3; } if ( !Aligned_1 ) goto LABEL_97; LABEL_95: if ( !*Aligned_1 ) operator delete(Aligned_1, 4 * n4_2 + 8); LABEL_97: n4_16 = n4_14; LABEL_83: n4_14 = n4_16 + 1; *((_DWORD *)Aligned + n4_16 + 2) = v71; if ( v68 != v67 ) { qword28_1 = (__int64 *)this->qword28; ++v68; v65 = *qword28_1; v70 = (qword28_1[1] - *qword28_1) >> 2; if ( v70 <= v68 ) goto LABEL_140; continue; } break; } LOBYTE(v13) = HIBYTE(this->attrib_flags); LABEL_102: v13 = (const google::protobuf::Message *)((unsigned __int8)v13 & 1); if ( (_DWORD)v13 ) { voidVec1 = this->qword30; v92 |= 0x20u; qword30_1 = voidVec1; } goto LABEL_25; case 2: qword28_2 = (__int64 *)this->qword28; if ( !qword28_2 ) goto LABEL_21; v50 = *qword28_2; v51 = (qword28_2[1] - *qword28_2) >> 3; if ( (int)v51 <= 0 ) goto LABEL_21; if ( !v51 ) { v55 = 0; v53 = 0; LABEL_138: std::__throw_out_of_range_fmt( "vector::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)", v53, v55); } v52 = (unsigned int)(v51 - 1); v53 = 0; while ( 2 ) { v56 = *(_QWORD *)(v50 + 8 * v53); n4_19 = n4_17; if ( n4_17 != n4_5 ) goto LABEL_64; v58 = v98; n4_4 = n4_17 + 1; if ( v98 ) { v60 = *(google::protobuf::Arena **)v98; if ( 2 * n4_17 >= n4_4 ) n4_4 = 2 * n4_17; if ( n4_4 < 4 ) n4_4 = 4; v61 = 8LL * n4_4 + 8; if ( v60 ) { v98 = (void *)google::protobuf::Arena::AllocateAligned( *(google::protobuf::Arena **)v98, (const type_info *)&`typeinfo for'char, v61); *(_QWORD *)v98 = v60; n4_18 = n4_17; n4_6 = n4_5; n4_5 = n4_4; if ( n4_17 <= 0 ) goto LABEL_76; goto LABEL_74; } } else { if ( 2 * n4_17 >= n4_4 ) n4_4 = 2 * n4_17; if ( n4_4 < 4 ) n4_4 = 4; v61 = 8LL * n4_4 + 8; } v98 = (void *)operator new(v61); *(_QWORD *)v98 = 0; n4_18 = n4_17; n4_6 = n4_5; n4_5 = n4_4; if ( n4_17 > 0 ) LABEL_74: memcpy((char *)v98 + 8, v58 + 1, 8 * n4_18); if ( !v58 ) goto LABEL_78; LABEL_76: if ( !*v58 ) operator delete(v58, 8 * n4_6 + 8); LABEL_78: n4_19 = n4_17; LABEL_64: n4_17 = n4_19 + 1; *((_QWORD *)v98 + n4_19 + 1) = v56; if ( v53 != v52 ) { qword28_3 = (__int64 *)this->qword28; ++v53; v50 = *qword28_3; v55 = (qword28_3[1] - *qword28_3) >> 3; if ( v53 >= v55 ) goto LABEL_138; continue; } break; } LOBYTE(v13) = HIBYTE(this->attrib_flags); LABEL_21: v13 = (const google::protobuf::Message *)((unsigned __int8)v13 & 1); if ( (_DWORD)v13 ) { qword30_2 = this->qword30; v92 |= 0x40u; qword30_3 = qword30_2; } v15 = BYTE1(this->attrib_type); if ( (v15 & 2) != 0 ) { v92 |= 0x100u; v114 = (v15 >> 2) & 7; } goto LABEL_25; case 3: qword28_4 = (__int64 *)this->qword28; if ( !qword28_4 ) goto LABEL_99; v34 = *qword28_4; v35 = *((unsigned int *)qword28_4 + 6) + 8 * (qword28_4[2] - *qword28_4) - *((unsigned int *)qword28_4 + 2); if ( (int)v35 <= 0 ) goto LABEL_99; if ( !v35 ) { v39 = 0; v37 = 0; LABEL_136: std::__throw_out_of_range_fmt( "vector<bool>::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)", v37, v39); } v36 = (unsigned int)(v35 - 1); v37 = 0; while ( 2 ) { n4_21 = n4_20; v41 = ((1LL << v37) & *(_QWORD *)(v34 + 8 * (v37 >> 6))) != 0; if ( n4_20 != n4_10 ) goto LABEL_45; v42 = v101; n4_8 = n4_20 + 1; if ( v101 ) { v44 = *(google::protobuf::Arena **)v101; if ( 2 * n4_20 >= n4_8 ) n4_8 = 2 * n4_20; n4_7 = 4; v85 = *(google::protobuf::internal::RepeatedPtrFieldBase **)v101; if ( n4_8 >= 4 ) n4_7 = n4_8; n4_9 = n4_7; v46 = n4_7 + 8LL; if ( v44 ) { v101 = (void *)google::protobuf::Arena::AllocateAligned(v44, (const type_info *)&`typeinfo for'char, v46); *(_QWORD *)v101 = v85; n = n4_20; n4_12 = n4_10; n4_10 = n4_9; if ( n4_20 <= 0 ) goto LABEL_57; goto LABEL_55; } } else { if ( 2 * n4_20 >= n4_8 ) n4_8 = 2 * n4_20; n4_11 = 4; if ( n4_8 >= 4 ) n4_11 = n4_8; n4_9 = n4_11; v46 = n4_11 + 8LL; } v84 = (_QWORD *)operator new(v46); n = n4_20; v101 = v84; *v84 = 0; n4_12 = n4_10; n4_10 = n4_9; if ( (int)n > 0 ) { LABEL_55: n4_13 = n4_12; memcpy((char *)v101 + 8, v42 + 1, n); n4_12 = n4_13; } if ( !v42 ) goto LABEL_59; LABEL_57: if ( !*v42 ) operator delete(v42, n4_12 + 8); LABEL_59: n4_21 = n4_20; LABEL_45: n4_20 = n4_21 + 1; *((_BYTE *)v101 + n4_21 + 8) = v41; if ( v36 != v37 ) { qword28_5 = (__int64 *)this->qword28; ++v37; v34 = *qword28_5; v39 = *((unsigned int *)qword28_5 + 6) + 8 * (qword28_5[2] - *qword28_5) - *((unsigned int *)qword28_5 + 2); if ( v39 <= v37 ) goto LABEL_136; continue; } break; } LOBYTE(v13) = HIBYTE(this->attrib_flags); LABEL_99: v13 = (const google::protobuf::Message *)((unsigned __int8)v13 & 1); if ( (_DWORD)v13 ) { qword30_4 = this->qword30; v92 |= 0x80u; qword30_5 = qword30_4; } LABEL_25: HDDMDevice::writeMessage((HDDMDevice *)fileName, (std::ostream *)attrib_msg, v13); HDDMXng::BelUsageAttrib::~BelUsageAttrib((HDDMXng::BelUsageAttrib *)attrib_msg); return; case 4: case 5: case 6: qword28_6 = (__int64 *)this->qword28; if ( !qword28_6 ) goto LABEL_105; v17 = *qword28_6; v18 = (qword28_6[1] - *qword28_6) >> 5; if ( (int)v18 <= 0 ) goto LABEL_105; if ( !v18 ) { v28 = 0; v20 = 0; LABEL_134: std::__throw_out_of_range_fmt( "vector::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)", v20, v28); } v19 = (unsigned int)(v18 - 1); v20 = 0; while ( 2 ) { v29 = v105; v21 = v104; v30 = 32 * v20 + v17; if ( !v105 ) goto LABEL_108; v31 = v103; v32 = *v105; if ( v103 >= *v105 ) { v21 = v104; if ( v32 == v104 ) { LABEL_108: google::protobuf::internal::RepeatedPtrFieldBase::Reserve( (google::protobuf::internal::RepeatedPtrFieldBase *)&v102, v21 + 1); v29 = v105; v32 = *v105; } *v29 = v32 + 1; v22 = v102; if ( v102 ) { v23 = (_QWORD *)google::protobuf::Arena::AllocateAligned( v102, (const type_info *)&`typeinfo for'std::string, 0x20u); v24 = v23; if ( v23 ) { v23[1] = 0; *((_BYTE *)v23 + 16) = 0; *v23 = v23 + 2; } google::protobuf::Arena::AddListNode( v22, v23, (void (*)(void *))google::protobuf::internal::arena_destruct_object<std::string>); v25 = v24; } else { v82 = operator new(0x20u); *(_QWORD *)(v82 + 8) = 0; *(_BYTE *)(v82 + 16) = 0; v25 = (_QWORD *)v82; *(_QWORD *)v82 = v82 + 16; } v26 = v103++; *(_QWORD *)&v105[2 * v26 + 2] = v25; } else { ++v103; v25 = *(_QWORD **)&v105[2 * v31 + 2]; } std::string::_M_assign(v25, v30); if ( v20 != v19 ) { qword28_7 = (__int64 *)this->qword28; ++v20; v17 = *qword28_7; v28 = (qword28_7[1] - *qword28_7) >> 5; if ( v28 <= v20 ) goto LABEL_134; continue; } break; } LOBYTE(v13) = HIBYTE(this->attrib_flags); LABEL_105: v13 = (const google::protobuf::Message *)((unsigned __int8)v13 & 1); if ( (_DWORD)v13 ) { v92 |= 2u; qword30_6 = this->qword30; if ( p__ZN6google8protobuf8internal26fixed_address_empty_stringB5cxx_1 == &google::protobuf::internal::fixed_address_empty_string[abi:cxx11] ) sub_E76770(&p__ZN6google8protobuf8internal26fixed_address_empty_stringB5cxx_1, qword30_6); else std::string::_M_assign(p__ZN6google8protobuf8internal26fixed_address_empty_stringB5cxx_1, qword30_6); } goto LABEL_25; default: goto LABEL_25; } } void __fastcall HDDMBelUsageAttrib::print(HDDMBelUsageAttrib *this, std::ostream *stream, std::string *filename) { char attrib_code_high; // al char v6; // al char n7; // al const char *unknown; // r15 __int64 v9; // r14 size_t v10; // rax __int64 v11; // r14 __int64 v12; // r14 size_t v13; // rax __int64 v14; // rax char v15; // al unsigned __int16 v16; // r14 unsigned __int8 v17; // si char n2; // al _QWORD *qword28_4; // rdx _QWORD *v20; // rax _QWORD *v21; // r13 _QWORD *qword30_1; // rbx char *_[MISMATCH]_2; // rax char *_[MISMATCH]_1; // rax char *_[MISMATCH]; // rax __int64 v26; // rax __int64 v27; // rax __int64 v28; // rax __int64 v29; // rax double **qword28_5; // rdx double *v31; // rax double *v32; // r13 unsigned int **qword28_3; // rdx unsigned int *v34; // rax unsigned int *v35; // r13 unsigned int voidVec1; // ebx __int64 voidVec; // rax _QWORD *v38; // r14 unsigned int n63; // r13d _QWORD *v40; // rcx int n63_1; // edx __int64 qword28_1; // rax __int64 qword28_2; // rax unsigned int voidVec1_low; // ebx char *s; // [rsp+8h] [rbp-60h] char *sa; // [rsp+8h] [rbp-60h] void *v47[2]; // [rsp+10h] [rbp-58h] BYREF _BYTE v48[72]; // [rsp+20h] [rbp-48h] BYREF v47[0] = v48; sub_F12340(v47, "", ""); if ( (this->attrib_flags & 0xFFF) != 0 ) std::string::append(v47, "W"); attrib_code_high = HIBYTE(this->attrib_flags); if ( (attrib_code_high & 4) != 0 ) { std::string::append(v47, "G"); attrib_code_high = HIBYTE(this->attrib_flags); } if ( (attrib_code_high & 0x40) != 0 ) std::string::append(v47, "E"); v6 = BYTE1(this->attrib_type); if ( (v6 & 2) != 0 ) { std::string::append(v47, "P"); v6 = BYTE1(this->attrib_type); } if ( (v6 & 0x40) != 0 ) { std::string::append(v47, "H"); if ( (this->attrib_type & 0x8000) == 0 ) goto LABEL_11; } else if ( v6 >= 0 ) { LABEL_11: n7 = (HIBYTE(this->attrib_flags) >> 3) & 7; goto LABEL_12; } std::string::append(v47, "B"); n7 = (HIBYTE(this->attrib_flags) >> 3) & 7; if ( n7 == 7 ) { LABEL_15: unknown = "unknown"; s = ""; goto LABEL_17; } LABEL_12: switch ( n7 ) { case 0: unknown = "unsigned"; s = ""; break; case 1: unknown = "int"; s = ""; break; case 2: _[MISMATCH] = ""; unknown = "double"; if ( (*(_QWORD *)&this->attrib_flags & 0xC00000000FFFLL) != 0 ) _[MISMATCH] = " [MISMATCH]"; s = _[MISMATCH]; break; case 3: unknown = "bool"; s = ""; break; case 4: unknown = "string"; s = ""; break; case 5: _[MISMATCH]_1 = ""; unknown = "bithex"; if ( (this->attrib_type & 0x8200) != 0 ) _[MISMATCH]_1 = " [MISMATCH]"; s = _[MISMATCH]_1; break; case 6: _[MISMATCH]_2 = ""; unknown = "bitbinary"; if ( (this->attrib_type & 0x4200) != 0 ) _[MISMATCH]_2 = " [MISMATCH]"; s = _[MISMATCH]_2; break; default: goto LABEL_15; } LABEL_17: v9 = std::__ostream_insert<char,std::char_traits<char>>(stream, *(_QWORD *)filename, *((_QWORD *)filename + 1)); v10 = strlen(unknown); std::__ostream_insert<char,std::char_traits<char>>(v9, unknown, v10); std::__ostream_insert<char,std::char_traits<char>>(v9, "[", 1); v11 = std::__ostream_insert<char,std::char_traits<char>>(v9, v47[0], v47[1]); std::__ostream_insert<char,std::char_traits<char>>(v11, "] ", 2); v12 = std::__ostream_insert<char,std::char_traits<char>>(v11, this->attrib_name, this->attribVoidVec); v13 = strlen(s); std::__ostream_insert<char,std::char_traits<char>>(v12, s, v13); std::endl<char,std::char_traits<char>>(v12); v14 = std::__ostream_insert<char,std::char_traits<char>>(stream, *(_QWORD *)filename, *((_QWORD *)filename + 1)); std::__ostream_insert<char,std::char_traits<char>>(v14, " ", 3); v15 = 0; if ( (this->attrib_flags & 0x2000000) != 0 ) { std::operator<<<std::char_traits<char>>(stream, " (HIDDEN=true)"); v15 = 1; } v16 = this->attrib_flags & 0xFFF; if ( v16 ) { std::__ostream_insert<char,std::char_traits<char>>(stream, " (Width=", 8); v26 = std::ostream::_M_insert<unsigned long>(stream, v16); std::operator<<<std::char_traits<char>>(v26, ")"); v17 = BYTE1(this->attrib_type); if ( (v17 & 2) == 0 ) goto LABEL_49; goto LABEL_48; } v17 = BYTE1(this->attrib_type); if ( (v17 & 2) != 0 ) { LABEL_48: std::__ostream_insert<char,std::char_traits<char>>(stream, " (percision=", 12); v27 = std::ostream::_M_insert<unsigned long>(stream, (v17 >> 2) & 7); std::operator<<<std::char_traits<char>>(v27, ")"); goto LABEL_49; } if ( !v15 ) { n2 = (HIBYTE(this->attrib_flags) >> 3) & 7; if ( n2 != 2 ) goto LABEL_23; goto LABEL_50; } LABEL_49: v28 = std::endl<char,std::char_traits<char>>(stream); v29 = std::__ostream_insert<char,std::char_traits<char>>(v28, *(_QWORD *)filename, *((_QWORD *)filename + 1)); std::operator<<<std::char_traits<char>>(v29, " "); n2 = (HIBYTE(this->attrib_flags) >> 3) & 7; if ( n2 != 2 ) { LABEL_23: if ( n2 == 3 ) { std::operator<<<std::char_traits<char>>(stream, " ( "); voidVec = this->qword28; if ( voidVec ) { v38 = *(_QWORD **)voidVec; n63 = *(_DWORD *)(voidVec + 8); v40 = *(_QWORD **)(voidVec + 16); n63_1 = *(_DWORD *)(voidVec + 24); while ( n63 != n63_1 || v38 != v40 ) { while ( 1 ) { std::ostream::_M_insert<bool>(stream, ((1LL << n63) & *v38) != 0); qword28_1 = this->qword28; v40 = *(_QWORD **)(qword28_1 + 16); n63_1 = *(_DWORD *)(qword28_1 + 24); if ( v40 != &v38[(n63 + 1LL) >> 6] || n63_1 != (((_BYTE)n63 + 1) & 0x3F) ) { std::__ostream_insert<char,std::char_traits<char>>(stream, ", ", 2); qword28_2 = this->qword28; n63_1 = *(_DWORD *)(qword28_2 + 24); v40 = *(_QWORD **)(qword28_2 + 16); } if ( n63 == 63 ) break; if ( ++n63 == n63_1 && v38 == v40 ) goto LABEL_74; } ++v38; n63 = 0; } } LABEL_74: if ( (this->attrib_flags & 0x1000000) != 0 ) { voidVec1_low = LOBYTE(this->qword30); std::__ostream_insert<char,std::char_traits<char>>(stream, " default=", 9); std::ostream::_M_insert<bool>(stream, voidVec1_low); } } else if ( n2 == 1 ) { std::operator<<<std::char_traits<char>>(stream, " ( "); qword28_3 = (unsigned int **)this->qword28; if ( qword28_3 ) { v34 = qword28_3[1]; v35 = *qword28_3; while ( v35 != v34 ) { while ( 1 ) { std::ostream::operator<<(stream, *v35++); v34 = *(unsigned int **)(this->qword28 + 8LL); if ( v35 == v34 ) break; std::__ostream_insert<char,std::char_traits<char>>(stream, ", ", 2); if ( v35 == *(unsigned int **)(this->qword28 + 8LL) ) goto LABEL_62; } } } LABEL_62: if ( (this->attrib_flags & 0x1000000) != 0 ) { voidVec1 = this->qword30; std::__ostream_insert<char,std::char_traits<char>>(stream, " default=", 9); std::ostream::operator<<(stream, voidVec1); } } else { std::operator<<<std::char_traits<char>>(stream, " ( "); qword28_4 = (_QWORD *)this->qword28; if ( qword28_4 ) { v20 = (_QWORD *)qword28_4[1]; v21 = (_QWORD *)*qword28_4; while ( v21 != v20 ) { while ( 1 ) { std::__ostream_insert<char,std::char_traits<char>>(stream, *v21, v21[1]); v21 += 4; v20 = *(_QWORD **)(this->qword28 + 8LL); if ( v21 == v20 ) break; std::__ostream_insert<char,std::char_traits<char>>(stream, ", ", 2); if ( v21 == *(_QWORD **)(this->qword28 + 8LL) ) goto LABEL_30; } } } LABEL_30: if ( (this->attrib_flags & 0x1000000) != 0 ) { qword30_1 = (_QWORD *)this->qword30; std::__ostream_insert<char,std::char_traits<char>>(stream, " default=", 9); std::__ostream_insert<char,std::char_traits<char>>(stream, *qword30_1, qword30_1[1]); } } goto LABEL_32; } LABEL_50: std::operator<<<std::char_traits<char>>(stream, " ( "); qword28_5 = (double **)this->qword28; if ( qword28_5 ) { v31 = qword28_5[1]; v32 = *qword28_5; while ( v32 != v31 ) { while ( 1 ) { std::ostream::_M_insert<double>(stream, *v32++); v31 = *(double **)(this->qword28 + 8LL); if ( v32 == v31 ) break; std::__ostream_insert<char,std::char_traits<char>>(stream, ", ", 2); if ( v32 == *(double **)(this->qword28 + 8LL) ) goto LABEL_55; } } } LABEL_55: if ( (this->attrib_flags & 0x1000000) != 0 ) { sa = (char *)this->qword30; std::__ostream_insert<char,std::char_traits<char>>(stream, " default=", 9); std::ostream::_M_insert<double>(stream, *(double *)&sa); } LABEL_32: std::operator<<<std::char_traits<char>>(stream, " ) "); if ( v47[0] != v48 ) operator delete(v47[0]); } void HDDMBelUsageAttrib::HDDMBelUsageAttrib(HDDMBelUsageAttrib *this) { __int16 word4; // ax word4 = this->attrib_type; LOWORD(this->attrib_flags) &= 0xF000u; BYTE2(this->attrib_type) &= 0xF0u; this->attribVoidVec = 0; this->attrib_flags |= 0xFFF000u; LOBYTE(this->qword18) = 0; HIBYTE(this->attrib_flags) = 0; LOWORD(this->attrib_type) = word4 & 0xFE00; BYTE1(this->attrib_type) = 0; HIWORD(this->attrib_type) |= 0xFFF0u; this->attrib_name = (char *)&this->qword18; LODWORD(this->qword40) = 0; this->qword48 = 0; *((_QWORD *)this + 12) = 0; *((_QWORD *)this + 10) = &this->qword40; *((_QWORD *)this + 11) = &this->qword40; this->qword30 = 0; this->qword28 = 0; } void HDDMBelUsageAttrib::~HDDMBelUsageAttrib(HDDMBelUsageAttrib *this) { char v2; // al void ***qword28_2; // r12 void **v4; // rbp void **v5; // rbx void **qword30; // rbx __int64 v7; // rax _QWORD *v8; // rdx _QWORD *v9; // r13 _QWORD *v10; // rbp unsigned __int64 v11; // r10 const char *v12; // rsi _QWORD *v13; // r8 _QWORD *v14; // rbx unsigned __int64 v15; // rcx _QWORD *_ZZN3hdi8tcltasks12native_cacheIP18HDDMBelUsageAttribE12t2n_ins; // r15 unsigned __int64 v17; // rsi __int64 v18; // r10 unsigned __int64 v19; // rtt __int64 v20; // r11 unsigned __int64 v21; // r9 __int64 **v22; // rdx __int64 *i; // rcx __int64 *v24; // rdi __int64 v25; // r8 unsigned __int64 v26; // rdx void **qword28_1; // rbx __int64 qword48; // rsi _QWORD *p_qword38; // rdi _QWORD *p_qword18; // r14 _QWORD *p_qword18_1; // rdi unsigned __int64 v32; // rdx void **qword28; // rbx __int64 v34; // [rsp+8h] [rbp-50h] HDDMBelUsageAttrib *p_this; // [rsp+18h] [rbp-40h] BYREF v2 = (HIBYTE(this->attrib_flags) >> 3) & 7; switch ( v2 ) { case 2: goto LABEL_40; case 3: qword28 = (void **)this->qword28; if ( qword28 ) { if ( *qword28 ) operator delete(*qword28); operator delete(qword28, 0x28u); } goto LABEL_44; case 1: LABEL_40: qword28_1 = (void **)this->qword28; if ( qword28_1 ) { if ( *qword28_1 ) operator delete(*qword28_1); operator delete(qword28_1, 0x18u); } LABEL_44: this->qword28 = 0; goto LABEL_45; } qword28_2 = (void ***)this->qword28; if ( qword28_2 ) { v4 = qword28_2[1]; v5 = *qword28_2; if ( v4 != *qword28_2 ) { do { if ( *v5 != v5 + 2 ) operator delete(*v5); v5 += 4; } while ( v4 != v5 ); v5 = *qword28_2; } if ( v5 ) operator delete(v5); operator delete(qword28_2, 0x18u); this->qword28 = 0; } qword30 = (void **)this->qword30; if ( qword30 ) { if ( *qword30 != qword30 + 2 ) operator delete(*qword30); operator delete(qword30, 0x20u); this->qword30 = 0; p_this = this; if ( !*(_BYTE *)hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::observers() ) goto LABEL_46; goto LABEL_17; } LABEL_45: p_this = this; if ( !*(_BYTE *)hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::observers() ) goto LABEL_46; LABEL_17: if ( !(_BYTE)`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::n2t_instance(void)::cache && __cxa_guard_acquire(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::n2t_instance(void)::cache) ) { hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::n2t_instance(void)::cache = hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::get_n2t_cache(); __cxa_guard_release(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::n2t_instance(void)::cache); } v7 = std::_Hashtable<HDDMBelUsageAttrib const*,std::pair<HDDMBelUsageAttrib const* const,Tcl_Obj *>,std::allocator<std::pair<HDDMBelUsageAttrib const* const,Tcl_Obj *>>,std::__detail::_Select1st,std::equal_to<HDDMBelUsageAttrib const*>,boost::hash<HDDMBelUsageAttrib const*>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<true,false,false>>::equal_range( hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::n2t_instance(void)::cache, &p_this); v34 = v7; v9 = v8; if ( (_QWORD *)v7 != v8 ) { v10 = (_QWORD *)v7; while ( 1 ) { if ( !(_BYTE)`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache && __cxa_guard_acquire(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache) ) { hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache = (_QWORD *)hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::get_t2n_cache(); __cxa_guard_release(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache); } v11 = v10[2]; v12 = (const char *)hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache[1]; v13 = *(_QWORD **)(*hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache + 8 * ((v11 + (v11 >> 3)) % (unsigned __int64)v12)); if ( !v13 ) break; v14 = (_QWORD *)*v13; v15 = *(_QWORD *)(*v13 + 24LL); while ( v11 + (v10[2] >> 3) != v15 || v11 != v14[1] ) { if ( *v14 ) { v15 = *(_QWORD *)(*v14 + 24LL); v13 = v14; v14 = (_QWORD *)*v14; if ( (v11 + (v10[2] >> 3)) % (unsigned __int64)v12 == v15 % (unsigned __int64)v12 ) continue; } goto LABEL_26; } if ( !v13 || !v14 ) break; if ( (_BYTE)`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache ) goto LABEL_29; if ( __cxa_guard_acquire(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache) ) goto LABEL_64; if ( (_BYTE)`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache ) goto LABEL_30; LABEL_55: if ( __cxa_guard_acquire(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache) ) { hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache = (_QWORD *)hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::get_t2n_cache(); __cxa_guard_release(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache); } LABEL_30: _ZZN3hdi8tcltasks12native_cacheIP18HDDMBelUsageAttribE12t2n_ins = hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache; v17 = hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache[1]; v18 = *hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache; v19 = v14[3]; v20 = 8 * (v19 % v17); v21 = v19 % v17; v22 = (__int64 **)(*hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache + v20); for ( i = *v22; ; i = (__int64 *)*i ) { v24 = (__int64 *)*i; if ( (_QWORD *)*i == v14 ) break; } v25 = *v14; if ( *v22 != i ) { if ( v25 ) { v26 = *(_QWORD *)(v25 + 24) % v17; if ( v21 != v26 ) { *(_QWORD *)(v18 + 8 * v26) = i; v25 = *v14; } } goto LABEL_37; } if ( !v25 ) { if ( i == hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache + 2 ) LABEL_67: _ZZN3hdi8tcltasks12native_cacheIP18HDDMBelUsageAttribE12t2n_ins[2] = v25; LABEL_62: *v22 = 0; v25 = *v24; goto LABEL_37; } v32 = *(_QWORD *)(v25 + 24) % v17; if ( v21 != v32 ) { *(_QWORD *)(v18 + 8 * v32) = i; v22 = (__int64 **)(*_ZZN3hdi8tcltasks12native_cacheIP18HDDMBelUsageAttribE12t2n_ins + v20); if ( *v22 == _ZZN3hdi8tcltasks12native_cacheIP18HDDMBelUsageAttribE12t2n_ins + 2 ) goto LABEL_67; goto LABEL_62; } LABEL_37: *i = v25; operator delete(v24); --_ZZN3hdi8tcltasks12native_cacheIP18HDDMBelUsageAttribE12t2n_ins[3]; hdi::tcltasks::native_cache_base::mark_invalid(v10[2]); hdi::tcltasks::native_cache_base::decr_refcount(v10[2]); v10 = (_QWORD *)*v10; if ( v9 == v10 ) { if ( !(_BYTE)`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::n2t_instance(void)::cache && __cxa_guard_acquire(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::n2t_instance(void)::cache) ) { hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::n2t_instance(void)::cache = hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::get_n2t_cache(); __cxa_guard_release(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::n2t_instance(void)::cache); } std::_Hashtable<HDDMBelUsageAttrib const*,std::pair<HDDMBelUsageAttrib const* const,Tcl_Obj *>,std::allocator<std::pair<HDDMBelUsageAttrib const* const,Tcl_Obj *>>,std::__detail::_Select1st,std::equal_to<HDDMBelUsageAttrib const*>,boost::hash<HDDMBelUsageAttrib const*>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<true,false,false>>::erase( hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::n2t_instance(void)::cache, v34, v9); goto LABEL_46; } } LABEL_26: if ( (_BYTE)`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache || !__cxa_guard_acquire(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache) ) { goto LABEL_28; } v14 = 0; LABEL_64: hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache = (_QWORD *)hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::get_t2n_cache(); __cxa_guard_release(&`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache); if ( !v14 ) { LABEL_28: v14 = 0; hdi::tcltasks::native_cache_base::error((hdi::tcltasks::native_cache_base *)"native_cache<> corrupt", v12); } LABEL_29: if ( (_BYTE)`guard variable for'hdi::tcltasks::native_cache<HDDMBelUsageAttrib *>::t2n_instance(void)::cache ) goto LABEL_30; goto LABEL_55; } LABEL_46: qword48 = this->qword48; p_qword38 = &this->qword38; p_qword18 = &this->qword18; std::_Rb_tree<std::string,std::pair<std::string const,unsigned short>,std::_Select1st<std::pair<std::string const,unsigned short>>,std::less<std::string>,std::allocator<std::pair<std::string const,unsigned short>>>::_M_erase( p_qword38, qword48); p_qword18_1 = (_QWORD *)*(p_qword18 - 2); if ( p_qword18_1 != p_qword18 ) operator delete(p_qword18_1); }
10-30
#include <rclcpp/rclcpp.hpp> #include <cv_bridge/cv_bridge.h> #include <image_transport/image_transport.hpp> #include <tf2_ros/transform_broadcaster.h> #include <geometry_msgs/msg/transform_stamped.hpp> #include <opencv2/opencv.hpp> #include <opencv2/calib3d.hpp> #include <sensor_msgs/msg/image.hpp> #include <sensor_msgs/msg/camera_info.hpp> #include <tf2_geometry_msgs/tf2_geometry_msgs.hpp> // 装甲板实际尺寸(单位:米) const double ARMOR_WIDTH = 0.13; const double ARMOR_HEIGHT = 0.055; const double HALF_WIDTH = ARMOR_WIDTH / 2.0; const double HALF_HEIGHT = ARMOR_HEIGHT / 2.0; class ArmorDetector : public rclcpp::Node { public: ArmorDetector() : Node("armor_detector") { // 订阅图像话题(需根据实际话题名修改) image_sub_ = image_transport::create_subscription( this, "/camera/image_raw", std::bind(&ArmorDetector::imageCallback, this, std::placeholders::_1), "raw", rmw_qos_profile_sensor_data); // 发布处理后的图像 image_pub_ = image_transport::create_publisher(this, "armor_detection_result"); // TF广播器 tf_broadcaster_ = std::make_unique<tf2_ros::TransformBroadcaster>(*this); // 初始化相机内参(需根据实际相机标定修改) camera_matrix_ = (cv::Mat_<double>(3, 3) << 1000.0, 0.0, 320.0, 0.0, 1000.0, 240.0, 0.0, 0.0, 1.0; dist_coeffs_ = cv::Mat::zeros(5, 1, CV_64F); // 定义装甲板3D角点(中心为原点) object_points_ = { {-HALF_WIDTH, -HALF_HEIGHT, 0.0}, // 左下 {HALF_WIDTH, -HALF_HEIGHT, 0.0}, // 右下 {HALF_WIDTH, HALF_HEIGHT, 0.0}, // 右上 {-HALF_WIDTH, HALF_HEIGHT, 0.0} // 左上 }; } private: void imageCallback(const sensor_msgs::msg::Image::ConstSharedPtr& msg) { try { // 转换为OpenCV图像 cv::Mat frame = cv_bridge::toCvShare(msg, "bgr8")->image; cv::Mat gray, binary; // 预处理:灰度化+二值化 cv::cvtColor(frame, gray, cv::COLOR_BGR2GRAY); cv::threshold(gray, binary, 200, 255, cv::THRESH_BINARY); // 轮廓检测 std::vector<std::vector<cv::Point>> contours; cv::findContours(binary, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE); // 灯条识别 std::vector<cv::RotatedRect> light_bars; for (const auto& contour : contours) { if (contour.size() < 5) continue; auto rect = cv::minAreaRect(contour); float aspect_ratio = std::max(rect.size.width, rect.size.height) / std::min(rect.size.width, rect.size.height); // 筛选灯条(长宽比和面积) if (aspect_ratio > 4.0 && rect.size.area() > 100.0) { light_bars.push_back(rect); } } // 配对灯条形成装甲板 if (light_bars.size() >= 2) { // 简化为取前两个灯条(实际需更复杂配对逻辑) auto& left_bar = light_bars[0]; auto& right_bar = light_bars[1]; // 获取装甲板角点 std::vector<cv::Point2f> image_points = { left_bar.center + cv::Point2f(0, -left_bar.size.height/2), right_bar.center + cv::Point2f(0, -right_bar.size.height/2), right_bar.center + cv::Point2f(0, right_bar.size.height/2), left_bar.center + cv::Point2f(0, left_bar.size.height/2) }; // PnP解算 cv::Mat rvec, tvec; cv::solvePnP(object_points_, image_points, camera_matrix_, dist_coeffs_, rvec, tvec, false, cv::SOLVEPNP_EPNP); // 计算装甲板中心坐标 double distance = cv::norm(tvec); cv::Point3f armor_center(tvec.at<double>(0), tvec.at<double>(1), tvec.at<double>(2)); // 重投影装甲板中心 std::vector<cv::Point3f> center_point = {{0, 0, 0}}; std::vector<cv::Point2f> projected_point; cv::projectPoints(center_point, rvec, tvec, camera_matrix_, dist_coeffs_, projected_point); // 绘制结果 for (int i = 0; i < 4; ++i) { cv::line(frame, image_points[i], image_points[(i+1)%4], cv::Scalar(0,255,0), 2); } cv::circle(frame, projected_point[0], 5, cv::Scalar(0,0,255), -1); cv::putText(frame, "Dist: " + std::to_string(distance) + "m", cv::Point(10,30), cv::FONT_HERSHEY_SIMPLEX, 0.7, cv::Scalar(0,255,0), 2); // 发布TF变换 publishTransform(rvec, tvec); } // 发布处理后的图像 auto result_msg = cv_bridge::CvImage(msg->header, "bgr8", frame).toImageMsg(); image_pub_.publish(result_msg); } catch (const cv_bridge::Exception& e) { RCLCPP_ERROR(this->get_logger(), "CV Bridge error: %s", e.what()); } } void publishTransform(const cv::Mat& rvec, const cv::Mat& tvec) { // 转换为tf2 Transform tf2::Transform transform; cv::Mat rotation_mat; cv::Rodrigues(rvec, rotation_mat); tf2::Matrix3x3 tf_rot( rotation_mat.at<double>(0,0), rotation_mat.at<double>(0,1), rotation_mat.at<double>(0,2), rotation_mat.at<double>(1,0), rotation_mat.at<double>(1,1), rotation_mat.at<double>(1,2), rotation_mat.at<double>(2,0), rotation_mat.at<double>(2,1), rotation_mat.at<double>(2,2)); transform.setBasis(tf_rot); transform.setOrigin(tf2::Vector3( tvec.at<double>(0), tvec.at<double>(1), tvec.at<double>(2))); // 创建TransformStamped消息 geometry_msgs::msg::TransformStamped tf_msg; tf_msg.header.stamp = this->now(); tf_msg.header.frame_id = "camera_frame"; tf_msg.child_frame_id = "armor_center"; tf_msg.transform = tf2::toMsg(transform); tf_broadcaster_->sendTransform(tf_msg); } image_transport::Subscriber image_sub_; image_transport::Publisher image_pub_; std::vector<cv::Point3f> object_Points; }; int main(int argc,char** argv) { rclcpp::init(argc,argv); auto node = std::make_shared<AromorDector>(); rclcpp::spin(node); rclcpp::shutdown(); return 0; }
08-05
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编码实践

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值