I'm trying to integrate Microsoft Speech Platform with Kinect and I've come across with the method: SpeechRecognitionEngine.InstalledRecognizers(), which doesn't run at all. When I call the method from my class the execution doesn't continue. I'm using this method to get the Kinect Recognizer.
What's the problem? This is the piece of code where I'm using the method InstalledRecognizers():
RecognizerInfo obtenerReconocedorKinect()
{
String details;
System.Collections.ObjectModel.ReadOnlyCollection<RecognizerInfo> recs = SpeechRecognitionEngine.InstalledRecognizers();
foreach (RecognizerInfo recInfo in recs)
{
if (recInfo.AdditionalInfo.ContainsKey("Kinect"))
{
details = recInfo.AdditionalInfo["Kinect"];
if (details == "True" && recInfo.Culture.Name == "en-US")
{
return recInfo;
}
}
}
return null;
}
Thanks in advance.
So the problem was:
a System.Runtime.InteropServices.COMException in Microsoft.Speech.dll with the following error: Not registered class REGDB_E_CLASSNOTREG
The issue has been solved by reinstalling the Kinect SDK.
Related
I am working with Unity and the Mixed Reality Toolkit. My issue is that "HP Reverb G2" is not detected using Windows Mixed Reality, but it works if I parse with SteamVR. My goal is to detect if the headset is on my head without using SteamVR.
My current solution, which doesn't work, is as follows:
public static bool IsHMDMounted()
{
if (headDevice == null || headDevice.isValid == false)
{
headDevice = InputDevices.GetDeviceAtXRNode(XRNode.Head);
}
if (headDevice != null)
{
bool presenceFeatureSupported = headDevice.TryGetFeatureValue(CommonUsages.userPresence, out bool userPresent);
if (headDevice.isValid && presenceFeatureSupported)
{
return userPresent;
}
else
{
return false;
}
}
else
{
return false;
}
}
There is a discussion related to this issue on the Unity forums - Question - OpenXR -- Is it no longer possible to get descriptive device names? - Unity Forum.
Referring to this thread, it seems that Unity does not expose the device information provided by Open XR, but you can get this information by intercepting the API of Open XR according to the method mentioned in the thread - https://forum.unity.com/threads/openxr-is-it-no-longer-possible-to-get-descriptive-device-names.1051493/#post-8275923.
So making a mobile application that works on UWP, IOS and Android but since not all librarys work on every platform I'm using the library based on what device is used by
if (Device.RuntimePlatform == Device.Android) { }
And I'm currently only working on the Android part of the application.
I'm using Android.Media to play a single audio file out of multiple speakers. And to do that I'm using a Picker that has the available audio output devices. This part works.
But I'm getting a error while trying to select the PreferredDevice:
Java.Lang.NoSuchMethodError: 'no non-static method "Landroid/media/MediaPlayer;.setPreferredDevice(Landroid/media/AudioDeviceInfo;)Z"'
The code line that is giving the error is:
mediaPlayer1.SetPreferredDevice(audioDeviceInfo);
the full method that is being run is:
newoutput.SelectedIndexChanged += (changed, args) =>
{
Context context = Android.App.Application.Context;
AudioManager audioMan = (AudioManager)context.GetSystemService(Context.AudioService);
AudioDeviceInfo audioDeviceInfo = audioMan.GetDevices(GetDevicesTargets.Outputs)[newoutput.SelectedIndex];
mediaPlayer1.SetPreferredDevice(audioDeviceInfo);
};
I can't find many examples that use the method and they don't usually go with a mediaplayer that is created by button press.
You can use this code
private AudioDeviceInfo findAudioDevice(int deviceType) {
AudioManager manager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] adis = manager.getDevices(GET_DEVICES_OUTPUTS);
for (AudioDeviceInfo adi : adis) {
if (adi.getType() == deviceType) {
return adi;
}
}
return null;
}
Then set your input:
audioRecord.setPreferredDevice(findAudioDevice([newoutput.SelectedIndex]));
We have an UWP application and we would like to have the following scenario:
open Microsoft word from it with a document
edit document
close document and get data to our application.
We have an Silverlight application that uses the code below and resolves the problem nicely. Can we do something similar in UWP? Programmatically open Word and wait for instance closing.
private void SetupWordInstance(bool visible = true)
{
if (AutomationFactory.IsAvailable)
{
_wordApp = null;
try
{
_wordApp = AutomationFactory.CreateObject("Word.Application");
_wordVersion = _wordApp.Version;
}
catch
{
try
{
_wordApp = AutomationFactory.CreateObject("Word.Application");
_wordVersion = _wordApp.Version;
}
catch (Exception)
{
Utils.ShowMessage(Resource.MissingWordApplicationErrorMessage);
}
}
if (_wordApp != null)
{
AutomationEvent beforeCloseEvent = AutomationFactory.GetEvent(_wordApp, "DocumentBeforeClose");
beforeCloseEvent.AddEventHandler(new BeforeCloseAppDelegate(BeforeCloseApp));
AutomationEvent quitEvent = AutomationFactory.GetEvent(_wordApp, "Quit");
quitEvent.AddEventHandler(new QuitAppDelegate(QuitApp));
if (visible)
{
_wordApp.Visible = true;
_wordApp.Activate();
FocusWordInstance();
}
}
}
else
{
Utils.ShowMessage(Resource.MissingAutomationErrorMessage);
}
}
There is a possibility that it can correspond by the technology called desktop bridge which Microsoft provides. Here's an explanation. Easily, it is to extract the Windows Desktop function not available in UWP and provide it together with application.
Docs/Windows/UWP/Develop/Porting apps to Windows 10/Desktop Bridge
The following is a sample when using Excel.
Desktop app bridge to UWP Samples
UWP calling Office Interop APIs
Windows Application Packaging Project Samples
Excel.Interop
Since the definition of Word API is below, it seems that it can be used as above.
Microsoft.Office.Interop.Word Namespace
I've downloaded the latest compiled version of FreeImage, then build FreeImageNet wrapper. Put FreeImage.dll and FreeImageNet.dll on the same folder as my executable (the sample code). But everytime I run it, it says freeimage.dll is missing. I modified the code on FreeImageWrapper.cs and remove the exception handler
public static bool IsAvailable()
{
/*try
{*/
// Call a static fast executing function
Version nativeVersion = new Version(GetVersion());
Version wrapperVersion = GetWrapperVersion();
// No exception thrown, the library seems to be present
return
(nativeVersion.Major > wrapperVersion.Major) ||
((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor > wrapperVersion.Minor)) ||
((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor == wrapperVersion.Minor) && (nativeVersion.Build >= wrapperVersion.Build));
}
/*catch (DllNotFoundException)
{
return false;
}
catch (EntryPointNotFoundException)
{
return false;
}
catch (BadImageFormatException)
{
return false;
}*/
}
It always throws BadImageFormatException. It seems the problem is on the native dll (freeimage.dll) ?
How do I fix it ?
Thanks in advance.
I'm using Visual C# 2010 Express
This happens very often if you try to load a unmanaged 32bit dll into a 64bit process. To get around this problem open the properties of your startup project and change under Built - PlatformTarget the type from Any CPU to x86.
I'm trying to open a mpg-File using emguCV. I use the following code:
if (instance == null)
{
lock (m_lock)
{
try
{
instance = new Capture(0); // capture from camera works fine if a camera is connected
}
catch (NullReferenceException)
{
String sFileName = #"C:\tmp\MarkerMovie.mpg";
try
{
if (File.Exists(sFileName))
{
instance = new Capture(sFileName); // here the exception is thrown
}
else
{
MessageBox.Show("No Camera and no Video-File found");
}
}
catch (NullReferenceException)
{
MessageBox.Show("Couldn't open Video: "+sFileName);
}
}
}
}
If a webcam is connected everything works fine, but when I unplug the webcam the line instance = new Capture(sFileName); throws a NullReferenceException:
Message = "Unable to create capture from C:\tmp\MarkerMovie.mpg"
I debugged and found the reason is in the constructor of capture. The following command always returns a Null-Pointer:
_ptr = CvInvoke.cvCreateFileCapture(fileName);
I could open the same video using C++ using this code:
cap = cvCaptureFromFile("C:\\tmp\\MarkerMovie.mpg");
I'm new to openCV, so I'm not sure which information you need to help me. I installed emguCV yesterday from http://sourceforge.net/projects/emgucv/ on a Windows XP computer. The installer-version is x86_2.3.0.1416. I included opencv_core231.dll, opencv_highgui231.dll and opencv_imgproc231.dll to my project.
Does somebody know how I can make this code working?
Let me know if you need more information.
Thanks.
I had the same problem and adding the opencv_ffmpeg.dll to the project seems to solve it. (Found in the bin directory in the Emgu CV directory) I have tried it on the project that you posted and it seems to be working too. Hope it helps.
With EmguCV in C#, you need to put the opencv_ffmpeg.dll, for example: opencv_ffmpeg2410.dll, be careful if you have x86 or 64 bits