| | 300 | } |
| | 301 | |
| | 302 | #if LANG_JP |
| | 303 | /// <summary> |
| | 304 | /// |
| | 305 | /// </summary> |
| | 306 | #else |
| | 307 | /// <summary> |
| | 308 | /// Gets the value of the current point |
| | 309 | /// </summary> |
| | 310 | #endif |
| | 311 | public CvScalar CurrentPoint()//out CvPoint current_coordinates) |
| | 312 | { |
| | 313 | /*int offset = Ptr.ToInt32() - _image.ImageData.ToInt32(); |
| | 314 | int y = offset / _image.WidthStep; |
| | 315 | int x = (offset - y * _image.WidthStep) / (3 * _image.ElemDepth); |
| | 316 | current_coordinates = new CvPoint(x, y);*/ |
| | 317 | int ch = _image.ElemChannels; |
| | 318 | CvScalar result = new CvScalar(); |
| | 319 | |
| | 320 | IntPtr ptr = _data.ptr; |
| | 321 | for (int j = 0; j < ch; j++) unsafe |
| | 322 | { |
| | 323 | switch (_image.ElemType) |
| | 324 | { |
| | 325 | case MatrixType.U8C1: |
| | 326 | case MatrixType.U8C2: |
| | 327 | case MatrixType.U8C3: |
| | 328 | case MatrixType.U8C4: |
| | 329 | result[j] = ((byte*)ptr)[j]; break; |
| | 330 | case MatrixType.S8C1: |
| | 331 | case MatrixType.S8C2: |
| | 332 | case MatrixType.S8C3: |
| | 333 | case MatrixType.S8C4: |
| | 334 | result[j] = ((sbyte*)ptr)[j]; break; |
| | 335 | case MatrixType.U16C1: |
| | 336 | case MatrixType.U16C2: |
| | 337 | case MatrixType.U16C3: |
| | 338 | case MatrixType.U16C4: |
| | 339 | result[j] = ((Int16*)ptr)[j]; break; |
| | 340 | case MatrixType.S16C1: |
| | 341 | case MatrixType.S16C2: |
| | 342 | case MatrixType.S16C3: |
| | 343 | case MatrixType.S16C4: |
| | 344 | result[j] = ((short*)ptr)[j]; break; |
| | 345 | case MatrixType.F32C1: |
| | 346 | case MatrixType.F32C2: |
| | 347 | case MatrixType.F32C3: |
| | 348 | case MatrixType.F32C4: |
| | 349 | result[j] = ((float*)ptr)[j]; break; |
| | 350 | case MatrixType.S32C1: |
| | 351 | case MatrixType.S32C2: |
| | 352 | case MatrixType.S32C3: |
| | 353 | case MatrixType.S32C4: |
| | 354 | result[j] = ((int*)ptr)[j]; break; |
| | 355 | case MatrixType.F64C1: |
| | 356 | case MatrixType.F64C2: |
| | 357 | case MatrixType.F64C3: |
| | 358 | case MatrixType.F64C4: |
| | 359 | result[j] = ((double*)ptr)[j]; break; |
| | 360 | default: |
| | 361 | // んなバカな |
| | 362 | throw new OpenCvSharpException(); |
| | 363 | } |
| | 364 | |
| | 365 | } |
| | 366 | |
| | 367 | return result; |