Good worktime!
I'm writing C# warp around Sony Remote API, using Android test app as an example.
There became a problem with Liveview.
I start liveview streaming by the API method "startLiveview". Liveview data consumer works in a separate thread and it simply passes through frames if there's no time to draw them all (just like in the test app, as far as i understand).
However, after the startLiveview method is processed and fetching stream is started, the camera experience some difficulties with all other API commands processing in time.
E.g., after my warp discovers the camera and connects to it, performs startRecMode and so on, it can take pictures very fast. However, since liveview is started, the camera can't process all actTakePicture calls in time. There can be seconds or even dozens of seconds i have to wait before the shutter clicks.
I've tried to stop liveview before starting picture taking. It doesn't matter - stopLiveview command experiences the same problem, it takes even minutes to process it (there are minutes to return from System.Net.WebClient.UploadString).
I've tried to use startLiveviewWithSize instead of startLiveview and to pass the smallest size available (there is "M" with Sony A7R i'm using). No result.
What can i do to successfully stop the liveview or, as a max wish, to get rid of performance penalties when the liveview is on?
Thank you in advance!
p.S. Using MS VS 2010, .NET Framework 3.5, Sony ILCE Alpha 7R camera, all preprocessing settings found are switched off.
Related
I developed an application to use hands to move mouse cursor. But in the limits of computer screen, the cursor stay slow and run for other locations. I think that it is happens because I use all sensor of kinect. How I can use just part of sensor?
Not sure what kinect you use, but the kinect one cannt dissable certain streams.
Its goes all over USB3 to your PC, and its up to your code if you subscribe to those streams or not, but it is delivered anyway.
i'm not realy sure for the older kinect, but i assume its the same.
i have noticed that speed can depend a lot on the hardware, how your usb3 behaves.
i have a beast of a laptop i7 though a small industrial i5 outperforms it when running my kinect programs.
what you can do trough is drop frames, till your calculation is ready. that would keep most apps smooth working, if you dont want that try to create faster code you need roughly about 20ms to finish what you want to do till the next frame arives.
Try to see if you have this block of code where you can modify your application to your needs.
//Creates a new frame reader for correlating multiple frame sources.
_reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body);
I'm having a problem with timing in XNA 4.0, writing in C# and using Visual Studio 2010 express.
I'm not writing a game exactly, but I'm trying to use XNA for it's simplified content pipeline, drawing, and timing. What I'm trying to do is write a program that can time a user's response to onscreen stimuli at very fine resolutions - less than 5 ms, ideally.
To do this, I need to call the update routine (so I can poll the keyboard) no less than once every 5 ms. Even in variable step timing, I can't get the timing below about 16 ms per call. This doesn't appear to have anything to do with the amount of processing that I do in my update and draw routines. I can comment out everything in both routines and the program still spends roughly 16.66 ms on each iteration.
In fixed step timing, I can set the target to about 60 iterations per second (16.66 ms between updates), but if I try to go any faster than that, the IsRunningSlowly flag is tripped, and the game seems to try to compensate - several iterations will run faster than 60 iterations per second, and then 1 iteration will run slower.
So I guess my question is this: is the 60 iterations per second the upper limit for XNA? Is it possible to circumvent it? Should I just ditch XNA altogether?
I really appreciate your time and knowledge. Thanks in advance.
The problem you are having is due to VSync. Disable it in XNA by adding this line to your game's constructor (assuming you have the default GraphicsDeviceManager graphics):
graphics.SynchronizeWithVerticalRetrace = false;
This will allow your game to run "fast as possible". This should be "good enough" for your purposes.
See this blog post for a description of timing in XNA.
If you wanted to get more fancy: For XNA on Windows I would consider using the Windows event loop and a high resolution timer directly. Note that Game in XNA (on Windows and Xbox 360) is entirely optional.
You'd want to move as many slow operations (eg: update and draw) and blocking operations (eg: vsync) off the main thread. Note that input in XNA can only be handled on the main thread. I think you can create the graphics device on a separate thread - although I have never tried it.
You should note that, if you are measuring reaction times, there is lag in between sending a "present" command to the GPU, and that content actually appearing on screen.
I'm not expert to XNA development, but, I know I have already similar "problem" in windows phone. (slowly problem).
When you have a lot of treatment, use multithreading programming,,
msdn : "Applications that use multithreading are more responsive to user input because the user interface stays active as processor-intensive tasks execute on separate threads. Multithreading is also useful when you create scalable applications, because you can add threads as the workload increases. "
Hope I help you...
Is there a sample code available online to get WinRT to determine if its a slow internet connection within the first second of a web-request call so that I can cancel the request and switch to a local file at the start of the program. Metro requirements expect the app to boot up under 5 seconds and I need my web-request (of 300kb) to return well before that. its usually fast on WiFi but 3G speed may vary.
You can see if you are running on a 3G or WiFi connection by using the connectioncost api.
When you are on 3G you could consider using the local file anyway and then attempt to update it on the background. Additionally you might increase your logic further by checking if the user is currently roaming or even if he or she is approaching his or her datalimit, all which might influence your decision on where to load from. All this can be done through the same API.
You are also mixing up things a little as far as the 5 seconds for your app to start go. Your app can actually take 15 seconds give or take to provide something and only 5 seconds to suspend before you are forcibly cut off. If the 15 seconds isn't enough to start with you can also replace the default splash screen .. with your own splash screen and continue loading as long as you like. Keep in mind your user might not like it.
Why not load the local file and then try to update it on the background? I am not sure about your use case.
When using SimpleOpenNI and processing I had a smooth skeleton view, about 30fps. Using VC# and the skeletal tracking example it seems like about 10fps. As if something was blocking it.
Why is it that slow and how do I make it as fast as in processing?
pastebin.com/1La80sRU is the c# code basis - it is the original.
I have tried your code, and to me it seems fine. I am using an Xbox-360 Kinect and the FPS is just fine. It seems to stumble a bit when you are first detected, but that is expected since it then requires more data. A video of me doing this can be found here. It also seems that your Kinect needs to warm up (slower at beginning => gets faster later on). My video does not show that since I started recording after Kinect was warmed up.
I'm working on a quite big application that is in charge of doing real-time motion tracking and camera movement controlling. Its tasks are:
Motion tracking (done by a native module, which decodes a video stream from a network camera and supplies both image buffers as big as 1280x720 pixels and the tracking results to the managed application via callbacks)
Receiving positioning feedback data from and sending movement data to a pan/tilt hardware about 20 times a second as well as zoom commands from/to the camera
Displaying the image data including live visualizations
Encoding and writing of the image and session data
Automatic postprocessing of the video is done by another process
The application uses .NET 4.0 and has a WPF user interface.
Managed threads freezing
From the beginning we had to face managed threads that freeze for between 500 to 1500ms, which is really much for a real-time application like this.
To find out when these hangs occur I created a thread whose only task is to do a sleep for 100ms all the time. I then calculated how long the sleep really took and got exactly the times when the camera movement stopped. It works very reliably, the threads all hang at the same time!
Unmanaged threads don't freeze
While all the managed threads freeze the unmanaged threads work without any problem. We check that by logs that are written independent from the managed part of the application.
Analysis
I tried to figure out with phenomenons could maybe cause this behaviour:
The whole machine slows down when we encounter these problems: Windows is responding very slowly (e.g. directory listings hang for half a minute in both Windows Explorer and my application, or launching applications takes incredibly long)
We read and write thousands of files at the same time (the tracking and postprocessing application), maybe this overcharges windows
The response of the GUI becomes very slow
The app uses about 1.3GB of virtual memory (according to Process.VirtualMemory64) / 500MB of working set memory (Process.WorkingSet64) - could it be that some of that is swapped onto the harddisk? (How can that be checked or solved?)
Of course if we kill the process Windows is responding fast again, but it takes Windows a while to be responding normally again
Hints on how to investigate into this would be highly appreciated. Thank you very much!
Maybe GC is working?
See the great article: http://samsaffron.com/archive/2011/10/28/in-managed-code-we-trust-our-recent-battles-with-the-net-garbage-collector
I would suggest taking a process dump as you are encountering the performance problem. You can do this several ways (taskmgr.exe or procdump.exe from SysInternals). Take a full memory dump.
Once you have the .dmp file, you can analyze it with windbg (or Visual Studio 2010). For managed processes you need to load the sos.dll extensions.
There are a lot of good windbg resources out there, but here are a few that have helped me:
1) Tess Fernandez video (ASP.NET process, but the techniques are the same)
2) WinDbg cheatsheet
The memory analysis will be able to give you the stack (!clrstack) while you are encountering the problem and tell you the exact culprit.