| 370 | |
| 371 | template<typename T> |
| 372 | void Array<T>::setFrom(const Matrix& cvMat) |
| 373 | { |
| 374 | try |
| 375 | { |
| 376 | if (!cvMat.empty()) |
| 377 | { |
| 378 | // New size |
| 379 | std::vector<int> newSize(cvMat.dims(),0); |
| 380 | for (auto i = 0u ; i < newSize.size() ; i++) |
| 381 | newSize[i] = cvMat.size(i); |
| 382 | // Reset data & volume |
| 383 | reset(newSize); |
| 384 | // Integrity checks |
| 385 | if (!mCvMatData.first || mCvMatData.second.type() != cvMat.type()) |
| 386 | error("Array<T>: T type and cvMat type are different.", __LINE__, __FUNCTION__, __FILE__); |
| 387 | // Fill data |
| 388 | cvMat.copyTo(mCvMatData.second); |
| 389 | } |
| 390 | else |
| 391 | reset(); |
| 392 | } |
| 393 | catch (const std::exception& e) |
| 394 | { |
| 395 | error(e.what(), __LINE__, __FUNCTION__, __FILE__); |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | template<typename T> |
| 400 | void Array<T>::setTo(const T value) |