diff --git a/SpaceStudioClient/Content/Blueprints/BP_KinectSaveData.uasset b/SpaceStudioClient/Content/Blueprints/BP_KinectSaveData.uasset new file mode 100644 index 0000000..227dc7d --- /dev/null +++ b/SpaceStudioClient/Content/Blueprints/BP_KinectSaveData.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfcdc71811f47e6bfff38c66b5576b6c1cfd7b7e4f36dcd1f1d1635f1221cc22 +size 26128 diff --git a/SpaceStudioClient/Content/Blueprints/BP_UDPMessageProcessor.uasset b/SpaceStudioClient/Content/Blueprints/BP_UDPMessageProcessor.uasset index 7828b8e..fa3d28d 100644 --- a/SpaceStudioClient/Content/Blueprints/BP_UDPMessageProcessor.uasset +++ b/SpaceStudioClient/Content/Blueprints/BP_UDPMessageProcessor.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:500b235dcb77e04cf955cc5c3ffb582ee89a7ed7119b22db6dceb55193567e17 -size 669633 +oid sha256:648c4061b535aabe8fc87e46c59a75a146036451f13214b97f49c687483bda0c +size 832194 diff --git a/SpaceStudioClient/Plugins/NeoKinectUnreal/Source/NeoKinectUnreal/Private/NeoKinectManager.cpp b/SpaceStudioClient/Plugins/NeoKinectUnreal/Source/NeoKinectUnreal/Private/NeoKinectManager.cpp index ff425b3..1a0e3ae 100644 --- a/SpaceStudioClient/Plugins/NeoKinectUnreal/Source/NeoKinectUnreal/Private/NeoKinectManager.cpp +++ b/SpaceStudioClient/Plugins/NeoKinectUnreal/Source/NeoKinectUnreal/Private/NeoKinectManager.cpp @@ -76,6 +76,9 @@ FFrameTextureData UNeoKinectManager::FramesData[static_cast(EKinectFrame: UNeoKinectManager* UNeoKinectManager::EventsDispatcher = nullptr; FTSTicker::FDelegateHandle UNeoKinectManager::TickerHandle; +float UNeoKinectManager::m_scale = 1.0f; +int UNeoKinectManager::m_shiftX = 0; +int UNeoKinectManager::m_shiftY = 0; #pragma endregion Statics //~ INITIALIZATION / UNINITIALIZATION @@ -1251,7 +1254,23 @@ cv::Mat rawImg = cv::Mat::zeros(cv::Size(1920, 1080), CV_8UC1); cv::Mat result = cv::Mat::zeros(cv::Size(960, 540), CV_8UC1); cv::Mat dst1 = cv::Mat::zeros(cv::Size(960, 540), CV_8UC1); cv::Mat dst2 = cv::Mat::zeros(cv::Size(960, 540), CV_8UC1); -cv::Mat showMat = cv::Mat::zeros(cv::Size(960, 540), CV_8UC1); +cv::Mat showMat = cv::Mat::zeros(cv::Size(1920, 1080), CV_8UC1); + + + +void UNeoKinectManager::SetScaleAndShift(float scale, int shiftX, int shiftY) +{ + m_scale = scale; + m_shiftX = shiftX; + m_shiftY = shiftY; + int orig_cx = showMat.cols / 2, orig_cy = showMat.rows / 2; + int new_cx = static_cast(orig_cx * m_scale); + int new_cy = static_cast(orig_cy * m_scale); + m_shiftX += new_cx - orig_cx; + m_shiftX += new_cy - orig_cy; +} + +cv::Mat affine_mat(2, 3, CV_64FC1); void UNeoKinectManager::UpdateFrames() { // if the game thread issued a shutdown, the textures may become invalid at any time @@ -1281,12 +1300,19 @@ void UNeoKinectManager::UpdateFrames() //applyMosaic(rawImg, 32); cv::resize(dst1, rawImg, cv::Size(FrameData.Width, FrameData.Height), 0, 0, cv::INTER_CUBIC); + affine_mat.at(0, 0) = m_scale; + affine_mat.at(0, 1) = 0; + affine_mat.at(0, 2) = m_shiftX; + affine_mat.at(1, 0) = 0; + affine_mat.at(1, 1) = m_scale; + affine_mat.at(1, 2) = m_shiftY; + warpAffine(rawImg, showMat, affine_mat, rawImg.size(), cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar(255)); RHIUpdateTexture2D( FrameData.Texture->GetRenderTargetResource()->GetRenderTargetTexture(), 0, FUpdateTextureRegion2D(0, 0, 0, 0, FrameData.Width, FrameData.Height), FrameData.Width * FrameData.PixelSize, - rawImg.data + showMat.data ); } else diff --git a/SpaceStudioClient/Plugins/NeoKinectUnreal/Source/NeoKinectUnreal/Public/NeoKinectManager.h b/SpaceStudioClient/Plugins/NeoKinectUnreal/Source/NeoKinectUnreal/Public/NeoKinectManager.h index b4adc0b..e5031ed 100644 --- a/SpaceStudioClient/Plugins/NeoKinectUnreal/Source/NeoKinectUnreal/Public/NeoKinectManager.h +++ b/SpaceStudioClient/Plugins/NeoKinectUnreal/Source/NeoKinectUnreal/Public/NeoKinectManager.h @@ -546,6 +546,8 @@ public: UFUNCTION(BlueprintPure, Category = "NeoKinect|Constants", meta = (Keywords = "length number size capability")) static int32 GetJointCount(); + UFUNCTION(BlueprintCallable, Category = "NeoKinect|Constants", meta = (Keywords = "body index scale and shift")) + static void SetScaleAndShift(float scale, int shiftX, int shiftY); /*//////////////////////////////////////////////////////////////////////////// BLUEPRINT FUNCTIONS END @@ -554,6 +556,9 @@ public: private: + static float m_scale; + static int m_shiftX; + static int m_shiftY; /** NeoKinect API sensor */ static NeoKinect::KinectSensor* Kinect; /** Does the sensor polling */