OpenCV with DirectX sample error - c++

I am trying to run an OpenCV with DirectX example: d3dsample.cpp from [here]. But it crashes on
initializeContextFromD3D11Device
The error is "Access violation executing ..." (look like it is not possible to initialize the context from D3D to OpenCL. I have no idea to solve with this problem.
I found some possible duplicate at OpenCV question board [here], but they are no any progress through last year.
If some one success to build this sample code, please give a suggestion.
PS: I am using OpenCV 3.1 on Visual Studio 2013 (vc120), Nvidia GTX980 graphics card.
Update:
I am trying to debug with both d3d10_interop and d3d11_interop.
The d3d10_interop gave me a exeption:
C:\OpenCV\3.1\sources\modules\core\src\directx.cpp:449: error:
(-222) OpenCL: Can't create context for DirectX interop in function
cv::directx::ocl::initializeContextFromD3D10Device\n" ...} ...}

Related

Error in opencv function in .exe file but not in debug nor release

One more time, I want to ask for your help after long and unfruitful researches.
I have developped an app using OpenCV which works very well is Visual Studio in debug and release mode.
I tried to deploy it, but i get a fatal error when I start the .exe. By using a log file and doing tests, I figured out the problem was in function cv::resize in the following code :
Mat logo = imread("lena.png");
cv::resize(logo, logo, Size(), 0.55, 0.55, INTER_CUBIC);
I found very weird that i can call cv::imread (and cv::Mat) without throwing exception but not resize.
If I try to run the .exe created by the compilation in release mode, i get the following errod code : 0xc000007b.
I read it could be a problem of compatibility between 32/64-bits dll, without being able to solve it. I try to build a 64-bits appplication. The path for opencv lib is define like this : C:\opencv\build\x64\vc14\lib
Thank you for your help,
Valentin B

Error during launch ITK/VTK project on ubuntu

I am trying to launch a ITK/VTQ project with Qt. The project runs on Windows 10, but not on Ubuntu.
I have the following error during launching the project:
X Error: BadColor (invalid Colormap parameter) 12
Major opcode: 1 (X_CreateWindow)
Resource id: 0x4a00001
How I can correct this error message ?
Have you tried running other OpenGL applications/games? There could be a problem with 3D graphics drivers on your Ubuntu. Also, without source code fragment for window creation, I doubt anyone can help you much further.

Compiling DirectX11 Shader Files

I am currently following the DirectX 11 tutorial from www.rastertek.com in the 2nd series of tutorials. I'm currently using VS2015 on a Windows7 x64. Following this tutorial has me using the Windows 10 kit.
I've successfully completed the first 3 tutorials and was able to render a colored window using DirectX 11. I've just completed tutorial 4 to render a colored triangle using the HLSL with a vertex & pixel shaders. I'm following this tutorial where both the vertex and pixel shaders are in separate files the only difference in my code is the file extension that I'm using. His website uses *.vs and *.ps respectively where I'm using *.vsh and *.psh since this gives me code highlighting. All of my class files compile correctly but when I begin to build out my solution I am getting this error.
1>------ Build started: Project: DirectX 11 Engine, Configuration: Debug x64 ------
1>FXC : error X3501: 'main': entrypoint not found
1>
1> compilation failed; no code produced
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The creator of this website does not have any contact information or community based forums. I do not know if this is an error within the website's tutorial or not. Now I know that this code has worked before using older versions of VS such as 2010, 2012 and 2013 on both Windows Vista and Windows 7 using both Windows 7 & Windows 8 kits from his first series of DirectX 10 & DirectX 11 tutorials. I wasn't able to find any help from www.msdn.com since some of their tutorials are written with the requirement of Windows 8 for DirectX 11 using VS2013. Their documentation is quite poor too.
One of the things that I have noticed that is different within DirectX 11 from the Windows Kit versus the deprecated June 2010 Direct X SDK release when Compiling a Shader file is as follows:
June 2010 Direct X SDK - Uses:
HRESULT result;
result = D3DX11CompileFromFile( "shaderFilename", NULL, NULL, "ShaderName", "*s_5_0" or "*s_5_1", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &pShaderBuffer, &pErrorMessage, NULL );
Versus...
This tutorial (Windows 10 kit from VS2015) - Uses:
HRESULT result;
result = D3DCompileFromFile( "shaderFilename", NULL, NULL, "ShaderName", "*s_5_0" or "*s_5_1", D3D10_SHADER_ENABLE_STRICTNESS, 0, &pShaderBuffer, &pErrorMessage );
Where the shader filename, shader name, feature level, and the shader buffer is either a Vertex or Pixel Shader Type. And the feature level being used in both these cases is "5_0" and not "5_1" even though I have specified both feature levels.
I'm not sure what has changed between the different compilers for DirectX's HLSL, and I don't understand where or why this error is being generated from. I do not know if the Shader Source code from the website's tutorial is missing something, or if there is some kind of property or setting in VS2015 not set right that I'm unaware of. I am open for any and all suggestions to help resolve this issue.
Visual Studio automatically compiles the shaders for you using FXC. Here, FXC reports that it cannot find the main entry point, i.e. the function main. This is the default, you have 2 solutions:
Assuming the VertexShader entry point is ColorVertexShader (it is in the tutorial you linked), change it to main
Change the entry point in the properties: Right click on file -> Properties -> HLSL Compiler -> General -> Entrypoint name
Because Visual Studio compiles the shaders for you, you don't have to compile them yourself via D3DCompileFromFile, consider using D3DReadFileToBlob to read the data, then passing them in CreateVertexShader from the ID3D11Device.
If you don't want to FXC to compile the shaders, you can Right click on file -> Properties -> General -> Item type - Change it to Does not participate in build
After I have submitted this question; I happened to stumble onto this question FXC : error X3501: 'main': entrypoint not found and from some of the comments and answers there. I simply ended up right clicking on the "color.psh" and "color.vsh" files and under their properties:
Configuration Properties -> General -> Excluded From Build section I set the flag to "Yes"
HLSL Compiler -> General -> Shader Type section I set the Shader Type respectively for Pixel & Vertex Shader For Each File.
HLSL Compiler -> General -> Shader Model section I set to Shader Model 5.0(/5_0) for both files.
Now every thing builds successfully and I am rendering a Green Triangle on a Black Windowed Background as expected.
The error message is quite explicit, the compiler is not able to find the entry point, by default it is main. My guess is that your shaders use something like vsmain or psmain...
If you look at the documentation of D3DCompileFromFile, then you will see that one parameter is the name of the entry point : https://msdn.microsoft.com/en-us/library/windows/desktop/hh446872(v=vs.85).aspx
Also, imagine that "*s_5_0" or "*s_5_1" is a pseudo code of you, or is a deprecated feature in recent C++ and here would just or two pointer and give true, and the compile function does not recognize wildcards.

CommandLineParser ,loading image in opencv by command line arguments

I see that in version 3 of Opencv , "CommandLineParser" is used much ;but I don't get how it works.I am new with programming.can anyone give me some help please?
another question is that , before I was working with Opencv 2 version , and reading image is quite simple by "Imread("file address",type)" but I see that in new version it is mostly done by commandine arguments . what is advantage of this,and how it works exactly?
I am working with Visual studio 2015 on Windows 10
thanks

OpenCV Fisher face error

i tried to run the fisher algorithm provided by openCV community.
http://docs.opencv.org/modules/contrib/doc/facerec/facerec_tutorial.html#tp91
But it produces the following error.
OpenCV Error: Image step is wrong (The matrix is not continuous, thus its number
of rows can not be changed) in unknown function, file
......\src\opencv\modules\core\src\matrix.cpp, line 802"
And found out that error is caused by,
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
model->train(images, labels); //Error occurs when i cal this method
Images i am feeding are the same size. following links say it could be due to release libraries.
OpenCV 2.0 C++ API using imshow: returns unhandled exception and "bad-flag"
Getting OpenCV Error "Image step is wrong" in Fisherfaces.train() method
But i removed all the release libraries from the project and using the debug mode in visual studio 2010. I am using OpenCV 2.4.5
But i could not go pass the error.
please help.
Thank you.