Open aloksharma1 opened 6 months ago
Here is my opencv build cmake logs and i was able to make a build from it, but whats next?
guys, i have built the opencvextern.dll but now i am getting error on trying to compile opencvsharp with x64 release config:
Build started at 12:28 AM...
1>------ Build started: Project: OpenCvSharp, Configuration: Release Any CPU ------
1>C:\Users\Alok\.nuget\packages\microsoft.build.tasks.git\1.1.1\build\Microsoft.Build.Tasks.Git.targets(25,5): warning : Could not find file 'F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\samples\.git'. The source code won't be available via Source Link.
1>C:\Users\Alok\.nuget\packages\microsoft.build.tasks.git\1.1.1\build\Microsoft.Build.Tasks.Git.targets(25,5): warning : Could not find file 'F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\samples\.git'. The source code won't be available via Source Link.
1>C:\Users\Alok\.nuget\packages\microsoft.build.tasks.git\1.1.1\build\Microsoft.Build.Tasks.Git.targets(25,5): warning : Could not find file 'F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\samples\.git'. The source code won't be available via Source Link.
1>C:\Users\Alok\.nuget\packages\microsoft.build.tasks.git\1.1.1\build\Microsoft.Build.Tasks.Git.targets(25,5): warning : Could not find file 'F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\samples\.git'. The source code won't be available via Source Link.
1>OpenCvSharp -> F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\bin\Release\netstandard2.1\OpenCvSharp.dll
1>OpenCvSharp -> F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\bin\Release\netstandard2.0\OpenCvSharp.dll
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\GpuMat.cs(7,19,7,23): error CS0234: The type or namespace name 'Util' does not exist in the namespace 'OpenCvSharp' (are you missing an assembly reference?)
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\GpuMatIndexer.cs(3,19,3,23): error CS0234: The type or namespace name 'Util' does not exist in the namespace 'OpenCvSharp' (are you missing an assembly reference?)
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\GpuMat.cs(1018,53,1018,57): warning CS8625: Cannot convert null literal to non-nullable reference type.
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\Stream.cs(272,84,272,88): warning CS8625: Cannot convert null literal to non-nullable reference type.
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\core\InputArray.cs(354,41,354,47): error CS0246: The type or namespace name 'GpuMat' could not be found (are you missing a using directive or an assembly reference?)
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\core\InputArray.cs(666,52,666,58): error CS0246: The type or namespace name 'GpuMat' could not be found (are you missing a using directive or an assembly reference?)
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\core\OutputArray.cs(265,42,265,48): error CS0246: The type or namespace name 'GpuMat' could not be found (are you missing a using directive or an assembly reference?)
total 565 error of this type, where do i need to reference the OpenCvSharpExtern release files? i tried putting them in opencvsharp solution folder and a x64 folder with this config in csproj folder:
<ItemGroup>
<None Update="x64\OpenCvSharpExtern.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>runtimes\win-x64\native\OpenCvSharpExtern.dll</TargetPath>
</None>
<None Update="x64\OpenCvSharpExtern.exp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>runtimes\win-x64\native\OpenCvSharpExtern.exp</TargetPath>
</None>
<None Update="\OpenCvSharpExtern.lib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>runtimes\win-x64\native\OpenCvSharpExtern.lib</TargetPath>
</None>
<None Update="x64\OpenCvSharpExtern.pdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>runtimes\win-x64\native\OpenCvSharpExtern.pdb</TargetPath>
</None>
</ItemGroup>
still the issue remains the same.
here is the dependency walker result, if that helps?
Hi @aloksharma1,
I want to start by saying that I don't have the same level of knowledge as @AvenSun, as I'm still new to this stuff, but I'll do my best to help.
Let's begin with some basic checks. Just to be sure, is the NuGet package for OpenCvSharp (not the runtime) installed in your project? (Sorry if this seems like a basic question.)
Are you trying to use the old OpenCvSharp implementation of GpuMat.cs, Stream.cs, etc? I think the OpenCvSharp implementation has changed so much that it is not compatible. I can't write up the solution to that here. This is probably not a problem on the C++ side, but on the C# implementation.
1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\GpuMat.cs(7,19,7,23): error CS0234: > > The type or namespace name 'Util' does not exist in the namespace 'OpenCvSharp' (are you missing an assembly reference?) 1>F:\CMakes\4.9\ShimatOpenCVSharp\opencvsharp\src\OpenCvSharp\Modules\cuda\GpuMatIndexer.cs(3,19,3,23): error > CS0234: The type or namespace name 'Util' does not exist in the namespace 'OpenCvSharp' (are you missing an assembly reference?)
As for the error message about the Util namespace not being found, there is currently an implementation at https://github.com/shimat/opencvsharp/tree/main/src/OpenCvSharp/Internal/Util
Hi Guys, First of All Thank you for your reply. I am not trying to use GpuMat implementation per say , just that my mat and operations are using cuda processors thats important even if syntax is changed i am ok with it.I'm just trying to build a cuda compatible version so I can leverage my gpu, the cpu process is super slow. @toita86 no, i am trying to build opencvsharp from source after successful compilation of opencv files & opencvexternextern folder. If i can use it without the compilation of opencvsharp project itself, please guide.
@shimat i will try your solution and will let you know before eod. i simply want gpu accelaration tow owkr with project.
Also one more question for you, my build log says:
-- FFMPEG: Downloading opencv_videoio_ffmpeg.dll from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fbac408a47977ee4265f39e7659d33f1dfef5216/ffmpeg/opencv_videoio_ffmpeg.dll
-- FFMPEG: Downloading opencv_videoio_ffmpeg_64.dll from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fbac408a47977ee4265f39e7659d33f1dfef5216/ffmpeg/opencv_videoio_ffmpeg_64.dll
-- FFMPEG: Downloading ffmpeg_version.cmake from https://raw.githubusercontent.com/opencv/opencv_3rdparty/fbac408a47977ee4265f39e7659d33f1dfef5216/ffmpeg/ffmpeg_version.cmake
so its downloading ffmpeg, is cmake making the cuda version of this dll? my thinking is since we have enabled cuda flags it should be doing that internally?
thanks
This is my guess, but there is only one opencv_videoio_ffmpeg(_64).dll available in the repository. The CUDA flag of the OpenCV cmake has no effect on the ffmpeg DLL selection.
Hello @shimat i tried your suggestion and the util folder is already present in in the code. please check the screenshot here
as for the gpu mat error, i dont understand it much i downloaded and followed instructions given by you in here https://github.com/shimat/opencv_files
The remaining Cuda
code in OpenCvSharp has not been maintained for a long time, and unless you know a lot both C# and C++, it will be difficult to solve the problem in the short term. I discontinued OpenCvSharp's CUDA support because I was tired of dealing with issues like the one here.
This is my last reply, but perhaps the errors in your screenshot could be solved by changing namespace from OpenCvSharp to OpenCvSharp.Internal.
In addition, the corresponding functions on the C++ side must be included in the compilation beforehand. Currently they are excluded by macros. https://github.com/shimat/opencvsharp/blob/50b50a1f715636def62f59f31e43bff8d4759d5b/src/OpenCvSharpExtern/cuda.h#L3
Hi @aloksharma1 sorry for late response, for my case after all the compilations i just took advantage of the performance gain obtained by changing the target from CPU to GPU(for example on the Computer Vision model).
Hi @aloksharma1 sorry for late response, for my case after all the compilations i just took advantage of the performance gain obtained by changing the target from CPU to GPU(for example on the Computer Vision model).
thanks after @shimat said he disabled gpu support, i switched back to original compiled opencv with cuda support on python and used zero mq for cross process communication.
hello i am using windows 11 and i have already checked 967 & #1668 , but as a c# dev i dont work with c++ much and these instructions are not clear for me (too advanced atm). I was hoping if you or anyone here can provide me with a step by step guide (please add a documentation for it, it will be big help instead of this "If you want to use the CUDA features, you need to customize the native bindings yourself.").
Thank you
@shimat @AvenSun