NOTICE: I'm Using Monodroid, expect C# code.
I'm facing this error when the _recorder.Start() is called.
CODE:
private void IniciarGrabacion()
{
try
{
CamcorderProfile camProfile = CamcordeProfile.Get(CamcorderQuality.High);
String outputFile = "/sdcard/trompiz.mp4";
_camera.Unlock ();
_recorder = new MediaRecorder();
_recorder.SetCamera(_camera);
_recorder.SetAudioSource(AudioSource.Default);
_recorder.SetVideoSource(VideoSource.Camera);
_recorder.SetProfile(camProfile);
_recorder.SetOutputFile(outputFile);
_recorder.SetPreviewDisplay(_preview.Holder.Surface);
_recorder.Prepare();
_recorder.Start(); // HERE IS WHERE THE ERROR APPEARS
}
catch(Exception ex)
{
string error = "Error starting Recording: " + ex.Message;
Log.Debug("ERROR",error);
Toast.MakeText(Application, error, ToastLength.Long).Show();
}
}
The outputFile is hardcoded because i'm still testing.
I can confirm that exists because it gets created.
I just figured the problem.
It wasn't on how the camera was handled.
It was the Profile setting.
CamcorderProfile camProfile = CamcordeProfile.Get(CamcorderQuality.High);
Might be a Device bug, but I cant set it to high. To make it work, I changed it to LOW.
CamcorderProfile camProfile = CamcordeProfile.Get(CamcorderQuality.Low);
I have a Zenithink C93 Z283 (H6_2f)
I hope this helps anyone else fighting with this...
Now I have to see how to record on High quality. I know I can because the native camera app records in high....
Related
My goal is to check if the system know/don't know the person who is sitting in front of my webcam.
First I tried it in a Console App and everythink worked fine but now I what to have a "nice" operlay in WPF and I inplement all in my WPF App even a Anti UI Block System but now I get a exeption
I know thats a big exeption. I'm sorry that the exeption is written in German (I can't change it). What is says: System.Net.Http.HttpRequestException: Error while sending and the remotehost closed a connection.
Here is the methode that triggers that exeption:
private static async Task<List<DetectedFace>> DetectFaceRecognize(IFaceClient faceClient, string path, string recognition_model)
{
try
{
FileStream fs = File.OpenRead(path);
IList<DetectedFace> detectedFaces = await faceClient.Face.DetectWithStreamAsync(fs, detectionModel: DetectionModel.Detection03);//Exeption triggert here
Console.WriteLine($"{detectedFaces.Count} face(s) detected from image `{Path.GetFileName(path)}`");
fs.Close();
return detectedFaces.ToList();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
return await DetectFaceRecognize(faceClient, path, recognition_model);
}
}
Can someone help me with this exeption?
Can you explicitly set the TLS version by adding the following line
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
I am having some trouble with this error in Visual Studio:
An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll
Additional information: The process cannot access the file 'C:\Users\aheij\Desktop\KinectOutput\swipe.txt' because it is being used by another process.
What I Have tried:
I have tried using these codes obtained from other solved StackOverflow questions similar to mine to try to solve the problem - but even that didn't seem to work?
Ive tried checking if the file is in use, but with no success.
I also run Visual Studio as administrator.
The file is not read-only.
The folder is not open, and the file is not being used in any other program when executing the code - at least not that I can see/know of.
The code:
So, to add some context to my code: I am writing some quick gesture detection code to the Kinect c# BodyBasics SDK v2 code freely available. This is a helper method that I added, that gets called in when a person is in view. If that person is executing the gesture, the method writes the frame time and gesture name to a text file.
Half the time, when the code does work, the gesture recognition works well. However, the other half of the time, the code breaks/stops because the writing to file bit causes the error.
Below is my code to see if the person is standing in the neutral position - its a bit waffly, so apologies about that. I have commented 'ERROR' where the error is (unsurprisingly):
private void Neutral_stance(VisualStyleElement.Tab.Body body, IReadOnlyDictionary<JointType, Joint> joints, IDictionary<JointType, Point> jointPoints, BodyFrame bf)
{
CameraSpacePoint left_hand = joints[JointType.HandLeft].Position;
CameraSpacePoint left_elbow = joints[JointType.ElbowLeft].Position;
CameraSpacePoint left_shoulder = joints[JointType.ShoulderLeft].Position;
CameraSpacePoint left_hip = joints[JointType.HipLeft].Position;
CameraSpacePoint right_hand = joints[JointType.HandRight].Position;
CameraSpacePoint right_elbow = joints[JointType.ElbowRight].Position;
CameraSpacePoint right_shoulder = joints[JointType.ShoulderRight].Position;
CameraSpacePoint right_hip = joints[JointType.HipRight].Position;
double vertical_error = 0.15;
double shoulderhand_xrange_l = Math.Abs(left_hand.X - left_shoulder.X);
double shoulderhand_xrange_r = Math.Abs(right_hand.X - right_shoulder.X);
if (bf != null)
{
TimeSpan frametime = bf.RelativeTime;
string path_p = #"C:\Users\aheij\Desktop\KinectOutput\Punch.txt"; //write to punch file
string path_s = #"C:\Users\aheij\Desktop\KinectOutput\swipe.txt"; //write to swipe file
if (left_hand.Y < left_elbow.Y)
{
if (right_hand.Y < right_elbow.Y)
{
if (shoulderhand_xrange_l < vertical_error)
{
if (shoulderhand_xrange_r < vertical_error)
{
Gesture_being_done.Text = " Neutral";
File.AppendAllText(path_p, frametime.ToString() + " Neutral" + Environment.NewLine); //ERROR
File.AppendAllText(path_s, frametime.ToString() + " Neutral" + Environment.NewLine); //ERROR
}
}
}
}
else
{
Gesture_being_done.Text = " Unknown";
File.AppendAllText(path_p, frametime.ToString() + " Unknown" + Environment.NewLine); //ERROR
File.AppendAllText(path_s, frametime.ToString() + " Unknown" + Environment.NewLine); //ERROR
}
}
}
Any solutions/ideas/suggestions to point me on the right track would be appreciated. I think that it would be good to use the 'using streamwriter' method as opposed to the method I am using here - but I am not sure how? Any help would be appreciated.
Additonal Info: Using Visual Studio 2015; Using windows 10.
Sidenote: I read somewhere that the Windows Search tool in Windows 10 can interfere and cause problems like this so I need to disable it?
As suggested to me I used the Filestream method & ensured the file was closed after use. But, even this still caused the same error.
Thus, I also got rid of having two file-writing actions in rapid succession of each other. I dont know if this is technically right or even true, but based off of this post here: link, my error could be coming up because I am trying to execute the second 'write to text file' line whilst the previous 'write to text file' line is still executing/writing to that same folder & location - hence the clash? Please someone, correct me if I am wrong.
Either way, this seems to have worked.
See below for my edited/corrected method:
private void Neutral_stance(Body body, IReadOnlyDictionary<JointType, Joint> joints, IDictionary<JointType, Point> jointPoints, BodyFrame bf)
{
//cameraspace point joint stuff here again (see original post for this bit leading up to the if statements.)
if (bf != null)
{
TimeSpan frametime = bf.RelativeTime;
string path_s = #"C:\Users\aheij\Desktop\KinectOutput\swipe.txt";
if (left_hand.Y < left_elbow.Y)
{
if (right_hand.Y < right_elbow.Y)
{
if (shoulderhand_xrange_l < vertical_error)
{
if (shoulderhand_xrange_r < vertical_error)
{
Gesture_being_done.Text = " Neutral";
FileStream fs_s = new FileStream(path_s, FileMode.Append); //swipe
byte[] bdatas = Encoding.Default.GetBytes(frametime.ToString() + " Neutral" + Environment.NewLine);
fs_s.Write(bdatas, 0, bdatas.Length);
fs_s.Close();
}
}
}
}
else
{
Gesture_being_done.Text = " Unknown";
FileStream fs_s = new FileStream(path_s, FileMode.Append);
byte[] bdatas = Encoding.Default.GetBytes(frametime.ToString() + " Unknown" + Environment.NewLine);
fs_s.Write(bdatas, 0, bdatas.Length);
fs_s.Close();
}
}
}
Do let me know if there is any way I can make this more elegant or anything else I should be aware of w.r.t this answer.
The code is based off of the code found here: FileStream Tutorial website
I have a very very strange issue going on with SSIS and wanted to know if anyone else has had something similar.
In a Data Flow I have a Source that gets data from a MSSQL table and then feeds it to a data transformation Script Task.
The script task is as follows:
Script Task
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
string SecurityHeader = (string)Variables.SecurityHeader;
string APIToken = (string)Variables.APIToken;
var AppFormID = (string)Row.AppFormID;
var AppClassName = (string)Row.AppClassName;
var Lat = Row.Latitude;
var Long = Row.Longitude;
var data = new
{
record = new
{
status = Row.Status.ToString(),
latitude = Row.Latitude,
longitude = Row.Longitude,
form_values = new Dictionary<string, string>()
}
};
if (Row.CreatedBy_IsNull == false) { data.record.form_values["1a09"] = Row.CreatedBy.ToString(); }
string jsonstring = JsonConvert.SerializeObject(data);
var client = new RestClient(AppURLRef);
var request = new RestRequest(Method.POST);
request.AddHeader(SecurityHeader, APIToken);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", jsonstring, ParameterType.RequestBody);
try
{
IRestResponse dataresponse = client.Execute(request);
if (dataresponse.StatusCode.ToString() == "Created")
{
var listobject = JsonConvert.DeserializeObject<Lists>(dataresponse.Content);
}
else
{
Row.OErrorMsg = dataresponse.ErrorMessage.ToString();
};
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " Data: " + ex.Data + " Inner Exception: " + ex.InnerException);
}
}
The Issue
When I run this without any break points I get a Message Box with the error "Input string was not in correct format"
Where this gets really weird is that when I put a break point in the code works perfectly, thus making getting a line error impossible.
Has anyone ever come across an issue like this before and if so how did you fix it?
Update
After following some advice I moved the try catch block up to the start of the script, this resulted in no change the try catch block was never hit.
I attempted to but a MessageBox.Show("") at the very top of the input process row and again this was not hit. Something is happening at a higher level than both of these thought I am unable to find out where or how this is occurring.
Again to reiterate the error is in a MessageBox, not in the output and nothing gets logged in the process tab. So this means no line numbers, no useful error messages that discusses where this error is occurring.
I managed to solve this, after commenting EVERYTHING out and removing all of the input columns the error was still occurring.
I put it down to another way Microsoft wants to punish me, I copied the code deleted the script task, added a new script task and copied the old code back in. Worked perfectly...
Thanks Microsoft!!
Put delay in catch block in next line to MessageBox.Show
you able to view message box .
Some time message box goes in back ground ( USe ALT +TAB to find it).
So, I downloaded the unity project from unity answers.
here is the link:
UnitySynth link to download page in unity answers
I have finished my prototype, but I'm getting errors when I tried to load a custom midi I downloaded from the web.
I got these error codes:
Error Loading Midi:
Midi Failed to Load!
UnityEngine.Debug:Log(Object)
CSharpSynth.Sequencer.MidiSequencer:LoadMidi(String, Boolean) (at Assets/Plugins/CSharpSynth/Sequencer/MidiSequencer.cs:153)
UnitySynthTest:Awake() (at Assets/Scripts/UnitySynthTest.cs:42)
NullReferenceException: Object reference not set to an instance of an object
CSharpSynth.Sequencer.MidiSequencer.Play () (at Assets/Plugins/CSharpSynth/Sequencer/MidiSequencer.cs:167)
UnitySynthTest.OnGUI () (at Assets/Scripts/UnitySynthTest.cs:161)
I would love to know an easy way to convert midis to mid.txt as the examples used in the demo.
EDIT:
The first error code, the one about not loading midi, comes from here:
public bool LoadMidi(string file, bool UnloadUnusedInstruments)
{
if (playing == true)
return false;
MidiFile mf = null;
try
{
mf = new MidiFile(file);
}
catch (Exception ex)
{
//UnitySynth
//THIS IS THE ERROR LINE **************************
Debug.Log("Error Loading Midi:\n" + ex.Message);
return false;
}
return LoadMidi(mf, UnloadUnusedInstruments);
}
The second one, the one about null reference exception comes from:
public void Play()
{
if (playing == true)
return;
//Clear the current programs for the channels.
Array.Clear(currentPrograms, 0, currentPrograms.Length);
//Clear vol, pan, and tune
ResetControllers();
//set bpm
// THIS IS THE ERROR LINE *****************************
_MidiFile.BeatsPerMinute = 120;
//Let the synth know that the sequencer is ready.
eventIndex = 0;
playing = true;
}
I solved my own question by removing the try and catch elements in the code, like this:
public bool LoadMidi(string file, bool UnloadUnusedInstruments)
{
MidiFile mf = File.Open(file, FileMode.Open);
return LoadMidi(mf, UnloadUnusedInstruments);
}
I dunno what happens here and if I should do that, but now even non .mid.txt files can be reproduced without problems.
BACKGROUND:
What I am trying to do is output a list of files which are unversioned or have had changes done to them and need to be commited.
WHAT IVE TRIED:
I am currently using the code below, the code runs but nothing is outputted to the console. The catch method isnt activated either as the message box doesnt appear.
using (SvnClient client = new SvnClient())
{
try
{
EventHandler<SvnStatusEventArgs> statusHandler = new EventHandler<SvnStatusEventArgs>(HandleStatusEvent);
client.Status(Properties.Settings.Default.LocalFolderPath + #"\" + project, statusHandler);
}
catch
{
MessageBox.Show("ERROR");
}
}
private void HandleStatusEvent(object sender, SvnStatusEventArgs args)
{
switch (args.LocalContentStatus)
{
case SvnStatus.NotVersioned: // Handle appropriately
Console.WriteLine(args.ChangeList);
break;
}
// review other properties of 'args'
}
Im not quite sure if this is the right code to get the list of files which need to be committed as the documentation is poor. Ive looked on this site and have found a few other methods (similar to this way) but I still cant get it working. can anyone help?