void updateFaceHeatMapsForPerson(Array<float>& heatMaps, const int person, const ScaleMode heatMapScaleMode, const float* heatMapsGpuPtr) { try { // Copy memory const auto channelOffset = heatMaps.getVolume(2, 3); const auto volumeBodyParts = FACE_NUMBER_PARTS * channelOffset; auto totalOffset = 0u; auto* heatMapsPtr = &heatMaps.getPtr()[person*volumeBodyParts]; // Copy face parts #ifdef USE_CUDA cudaMemcpy(heatMapsPtr, heatMapsGpuPtr, volumeBodyParts * sizeof(float), cudaMemcpyDeviceToHost); #else //std::memcpy(heatMapsPtr, heatMapsGpuPtr, volumeBodyParts * sizeof(float)); std::copy(heatMapsGpuPtr, heatMapsGpuPtr + volumeBodyParts, heatMapsPtr); #endif // Change from [0,1] to [-1,1] if (heatMapScaleMode == ScaleMode::PlusMinusOne) for (auto i = 0u ; i < volumeBodyParts ; i++) heatMapsPtr[i] = fastTruncate(heatMapsPtr[i]) * 2.f - 1.f; // [0, 255] else if (heatMapScaleMode == ScaleMode::UnsignedChar) for (auto i = 0u ; i < volumeBodyParts ; i++) heatMapsPtr[i] = (float)intRound(fastTruncate(heatMapsPtr[i]) * 255.f); // Avoid values outside original range else for (auto i = 0u ; i < volumeBodyParts ; i++) heatMapsPtr[i] = fastTruncate(heatMapsPtr[i]); totalOffset += (unsigned int)volumeBodyParts; } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); } }
void ImageDirectoryReader::set(const int capProperty, const double value) { try { if (capProperty == CV_CAP_PROP_FRAME_WIDTH) mResolution.x = {(int)value}; else if (capProperty == CV_CAP_PROP_FRAME_HEIGHT) mResolution.y = {(int)value}; else if (capProperty == CV_CAP_PROP_POS_FRAMES) mFrameNameCounter = fastTruncate((long long)value, 0ll, (long long)mImageDirectoryPath.size()-1); else if (capProperty == CV_CAP_PROP_FRAME_COUNT || capProperty == CV_CAP_PROP_FPS) log("This property is read-only.", Priority::Max, __LINE__, __FUNCTION__, __FILE__); else log("Unknown property", Priority::Max, __LINE__, __FUNCTION__, __FILE__); } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); } }