我知道非常小的C ++。我试图将编写C ++的代码转换为C#。但我无法转换此代码:
/* Convert the angle into predefined 3x3 neighbor locations
| 2 | 3 | 4 |
| 1 | 0 | 5 |
| 8 | 7 | 6 |
*/
for( int y = 0; y < grad_dir.rows; y++ ) {
float * grad_ptr = grad_dir.ptr<float>(y);
for( int x = 0; x < grad_dir.cols; x++ ) {
if( grad_ptr[x] != 0 )
grad_ptr[x] = toBin( grad_ptr[x] );
}
}
托宾:
int RobustTextDetection::toBin( const float angle, const int neighbors ) {
const float divisor = 180.0 / neighbors;
return static_cast<int>( (( floor(angle / divisor) - 1) / 2) + 1 ) % neighbors + 1;
}
grad_ptr.Ptr返回IntPtr但它不是数组,因此编译器给出了错误。如何将其转换为C#