User talk:Ginku

From Epic Wiki
Jump to: navigation, search

Hello All!

Feel free to ask questions here. I'm not quite an expert but I know my way around making games in unreal. =D

Q: Question?

A: Answer!

Source Code of OpenCV Plugin

Hey Ginku,

Why don't you share the source code on GitHub ? I would like to understand how you made / connected OpenCV and UE4. If we work together we could support more features of OpenCV.. --I just reworked this wiki article about linking DLLs.

Best Greetings XenoEgger

Hey XenoEgger,

Great idea! The plugin code can now be found here.


OpenCV plugin - Aruco - UE 4.9.2

Hello Ginku,

I followed your tutorial, which is great!

Unfortunately, at runtime I get a runtime error on this line: Direct3DDeviceIMContext->UpdateSubresource(Texture->GetResource(), MipIndex, &DestBox, SourceData, SourcePitch, 0); Which in line 1525 of "Epic Games\4.9\Engine\Source\Runtime\Windows\D3D11RHI\Private\D3D11Texture.cpp"

Have you got an idea of what is the cause?

Thank you Bruce

A: I have updated the tutorial/plugin for 4.14.0 and opencv 3.0. Are you still receiving this error? I was unable to replicate this problem on Win 10 64 bit.

Virtual reality individual eye rendering

Hi Ginku,

i need to render 2 billboards for individual eye in oculus .



Bug with the OpenCV code

Hi Ginku

Thanks very much for the OpenCV tutorial! I've used it as a starting point and its been great so far.

One thing that was puzzling me for a while was just totally random crashes for what seemed like no reason - very much felt like an out of bounds memory request. I believe the culprit is in this line:

UpdateTextureRegions(VideoTexture, (int32)0, (uint32)3, VideoUpdateTextureRegion, (uint32)(4 * VideoSize.X), (uint32)4, (uint8*)Data.GetData(), false);

If you change the second parameter to (uint32)1 you resolve this issue. I think you may have been using code from a couple of different places, but for our set up we only have one texture region (i.e. the whole image). The cause behind random crashing is that sometimes we'll be totally fine to read a RegionsIndex greater than 0 from Regions, but other times it will read out of bounds. Also fixing this bug should give a bit of a performance boost!

A: Thank you for the advice! :)

Packaging the OpenCV Plugin with a Game

Hi Ginku,

Thanks for sharing your OpenCV plugin! I'm working in 4.10.4 and using your plugin to capture a webcam. I've got everything working in the editor but when I package the game, it crashes immediately, I think due to OpenCV not being properly packaged (missing .dlls or something). The top of my stacktrace is:

Unknown exception - code c06d007e (first/second chance not available)


KERNELBASE ShooterGame_Win64_DebugGame!__delayLoadHelper2() [f:\dd\vctools\delayimp\delayhlp.cpp:323] ShooterGame_Win64_DebugGame!_tailMerge_opencv_world300_dll() ShooterGame_Win64_DebugGame!AWebcamReader::AWebcamReader() [c:\users\admin\documents\unreal projects\shootergame\source\shootergame\private\ui\webcamreader.cpp:19]

Are you aware of additionally steps I need to take beyond your wiki guide and readme in order to properly package the plugin with the game?


A: I believe all you need to do is include the 'opencv_world300.dll' file in the same directory as your packaged game's executable (project.exe). This was briefly mentioned in the tutorial. That dll file is located in the ThirdParty/library folder for your convenience.  :) On a side note, the opencv module/plugin will need to be edited if you want to support more than just the windows OS. You will also need to include the additional ThirdParty files with your release.

Instructions for UE 4.12.2? (current instructions do not work)


EU4 version 4.12.2 with Visual Studio 2015 gives a bunch of errors with your instructions. I'm using OpenCV 3.1.0 but the errors are not (yet) related to that issue.

"error CS0103: The name 'PublicIncludePaths' does not exist in the current context" And all other Public* variables give the same error, also Definitions, but that is contained in the CPPEnvironmentConfiguration variable of SetupGlobalEnvironment().

Also the ModulePath getter reports an error, suggests using ModuleDirectory variable instead of the obsolete GetModuleFilename().

"error CS0619: 'UnrealBuildTool.RulesCompiler.GetModuleFilename(string)' is obsolete: 'GetModuleFilename is deprecated, use the ModuleDirectory property on any ModuleRules instead to get a path to your module.'" suggests some easier way of third party .dll deployment configuration.

Can you check that your instructions work for the latest and current UE release?

A: I have updated my tutorial/plugin for 4.14.0 and opencv 3.0. I never ran into the 'PUblicIncludePaths' error, but I was able to replicate and fix the ModulePath getter problem, which was a simple API change fix. If you are still encountering errors with 3.1, I may update to that version of opencv if I can find the time. :)

Revision for UE 4.13?

I've been struggling with getting OpenCV working for a couple weeks now, and I am sadly on the edge of giving up. (Some of my attempts described at: I don't suppose there's any chance of an update to your OpenCV instructions and/or library? I am happy to play the guinea pig here, if you want one.

A: There was a small API change relating to getting the current module path for a given plugin. I have fixed that issue in my tutorial and plugin, and updated the binaries for version 4.14. :)

UE 4.13.2, cv::findContours always crashes

Q: Hey !

I wonder if [you/someone] already tried to use cv::findContour [with your plugin/any other OpenCV version] ? I'm actually using my own build of OpenCV 2.4.13. But I encouter the very famous "findContour" memory issue (just typing "findContours crash" in Google give dozens of results haha). So I'm pretty sure it's about compilation settings conflicts between unreal and OpenCV but I can't manage to figure it out.

At least, what I can say is that it's not an issue with "/MD" flags cause it's already enabled withing UnrealBuildTool.

I'm using Visual Studio 2015.

Best regards.


I figured it out with this thread I've made my own DLL project, put the cv::findCountour code related in the DLL, compiled with /MT runtime library (/MD causes crash), then linked to my Unreal Project as usual and it works !

UE4 OpenCV Frame Rate + Resolution issues

Hey Ginku,

I was able to get your plugin working in UE4.12.5, but there's a couple problems and I was wondering if you could help:

- The game's frame rate seems pinned to the camera's frame rate, currently stuck at 30fps. In the profiler it shows almost all the wait time is coming from Tick and WorldTick which is why I suspect the camera. Is that expected behavior for the plugin?

- Changing the resolution with SetResolution crashes Unreal, otherwise it only seems to work at 640x480. I've tried a couple different webcams now, both are capable of 1920x1080 so I'm not sure what the issue is here.

Any thoughts on what I could do to remedy those two issues?


A: This tutorial is meant to be simple. I would -really- recommend doing the webcam frame fetching in another thread. Maybe Rama's tutorial could help getting you started? :)

Good luck! -Ginku

CV::VideoCapture -> read fail.

Hey Ginku, Thanks to your plugin,I was using OPENCV with UE4 to read a camera,but there's a couple problems and I was wondering if you could help:

I used cv::Videocapture to open the camera,and then use Read( ) function to read the frame data from the camera.It worked well in the UE4 editor mode.When the program was packed or run in the standalone mode,the Read() function return false and can not read anything from the camera.The camera statue is open.

Could you please give me some suggestions to figure it out?

Best regards.


I was able to package the plugin (the new OpenCV 3.2 version) with windows and get it to read the webcam. Be sure to copy the dll's (opencv_word320 and opencv_ffmpeg320_64) into the WindowsNoEditor/PROJECTNAME/ folder (you should see a PROJECTNAME.exe in that folder), otherwise the game won't be able to find the opencv library and crash the first time opencv code is called! If you aren't using windows, just make sure the libraries are wherever the executable is, or alternatively in a system path.

Note: for windows, there are 2 executable! The one in WindowsNoEditor, and the one in WindowsNoEditor/PROJECTNAME. The actual executable is the one in the PROJECTNAME folder, and so that is the one that needs access to the dll's.

Good luck, -Ginku

Not really a question

but I wanted to say thanks for the guide, it's been incredibly useful, cheers pal. Phil

You're welcome! Glad it could be of help. :)


Problem Installing OpenCV

Hello there Ginku!

I am trying to follow your tutorial on installing your OpenCV plugin for Unreal. While I can get Unreal to show the plugin in the editor, when I go to enable it it prompts me to restart the editor then it tells me that the module UE4Editor-OpenCV.dll is either missing or built in another version. When I say to rebuild it, it says that it cannot compile and to try to compile the source manually. Why is this happening and how do I fix it? I would really appreciate the help.

Thanks so much, Mike