interactor issue using Chrome - xtk

I'm using Chrome 24.0.1312.56 (portable version) and 25.0.1364.97 m (installed version) to display some 3D contents. The interation in the 3D scene is not optimal. When I click and move slowly, there is no rotation in the scene. If I move quicker, the interaction starts. It means that I have to interact relatively quickly to mo the 3D scene. This behavior is not seen on firefox 18.0.2.
It looks like there is a minimal movement (or speed movement) under which, the event is thrown away.
The "bug" is worst when the move is in the Y axis of the viewport. Moving in the X axis is better, but not "normal".
Is chrome catching or not propagating some moves to xtk? Is there a threshold for the minimal move or speed?
Thanks,
Laurent.

Yes, I can reproduce if I move the mouse really, really slow..
There is a threshold as defined in here
https://github.com/xtk/X/blob/master/io/interactor.js#L993
The threshold seems reasonable for me. Are you moving really, really slow? We could expose the threshold via a setter.

Related

How to preprocess video for better OpenCV tracking?

I am trying to improve my webcam based OpenCV mouse controller for disabled people (MFC C++ application): https://preability.com/face-controlled-mouse/
The cursor moves, when a person moves her/his head, clicks when smile, etc.
Controller finds face area then use goodFeaturesToTrack, cornerSubPix and calcOpticalFlowPyrLK.
In general, I managed to stabilize cursor if lighting is good.
What I use now:
Evaluating and filtering the direction of the each corner point movement.
Spreading the corner points all over the face area for cv::goodFeaturesToTrack() helped a little too.
EWMA (or Kalman) filter for the cursor position.
I’ve included equalizeHist() for the face ROI. The detector performed much better in low light conditions.
In addition, I tried morphology operations of OpenCV without improvement.
However, the corner points still dance in uneven lighting.
I can see that similar old program eViacam has preprocessing module for webcam Creavision (old too) and the corner points are more stable.
Please advise what can be done with the input Mat? Or how can the video be processed with reasonable CPU loading?
Now I can answer my own question. Christoph Rackwitz gave me some good advice:
don’t track the whole head. track each feature. and don’t use those trackers, they’re too complex. use MOSSE. it’s dumb but very precise, as long as the object (which should be a tiny feature on the face) doesn’t change much.
MOSSE approaches optical flow. methods to calculate optical flow work like MOSSE, except they use simpler math and smaller regions, hence the result is noisier. MOSSE uses a larger area (for a single track/point of course) and more sophisticated math, for a more accurate result.
When MOSSE algorithm tracks “corner points”, cursor moves much more smoothly. There was a slight issue with discrete movement as the object rectangles moved the same number of pixels at the same time. Cursor moved in leaps. So, I had to use filter on each tracked point. Anyway, as you can see in the video, the CPU load did not increase comparing to Lukas-Kanade optical flow algorithm + filtration only cursor position. In good light, the difference is also very noticeable.
https://www.youtube.com/watch?v=WKwuas0GVkA
Lucas-Kanade optical flow:
goodFeaturesToTrack,
cornerSubPix,
calcOpticalFlowPyrLK,
cursor EWMA filter
MOSSE object tracking:
goodFeaturesToTrack,
cornerSubPix,
TrackerMOSSE,
all points EWMA filtration
And of course I had to remember to include the tracking453.lib to Linker when add legacy Tracker. I spent half a day googling the “unresolved external symbol LNK2001 error”. For some reason including a tracker from the core library (cv::Tracker) does not result such compilation error, so it is confusing.

Working with touches on a zoomed layer

I have a CCLayerPanZoom subclass. For testing purposes I put a sprite in the middle of the screen. I do the following test before and after zooming:
if(CGRectContainsPoint(mySprite.boundingBox,touchedPoint))
NSLog(#"Touch inside the sprite");
Before zooming I get "Touch inside the sprite" output, but when it's zoomed I don't. I have asked a similar question (Getting different x and y coordinates for touched location on a zoomed view) and figured it out later. But the solution I found works only for when panning, not for zooming. There're lots of games out there and this must be super simple (at least done prior to me). I need to be able to have the touched point the same as it was before zooming.
I regret all the wasted time to find a way out from this problem. It turns out that there's a neatly packed method called convertToNodeSpace in Cocos2D that lifts all the heavy weight. No need to make all those crazy calculations to take the panned distance and zoomed scale into account. I just did the following and everything worked like a magic
touchedPoint=[self convertToNodeSpace: touchedPoint];
where self is a subclass of CCLayerPanZoom which is a subclass of CCLayer. That's all. Hope this helps someone.

OpenGL object & camera resistance?

I'm developing a very basic came In C++ with openGL and GLUT where you move the "camera" around as the player.
In short:
My camera slows down when I look at a snowman
Full explanation:
Everything was fine until I decided to finally add in an object (a giant snowman in fact), but now I've added it, I'm experiencing very odd behaviour.
If I look at the snowman object and attempt to move forward, It feels like I'm moving against a force, as if I was walking through mud.
Now If I face opposite the snowman, and "walk" backwards with the camera, It moves completely fine, but when I look at it... I slow down. I've tried different scales of the snowman, and the larger the snowman is, the further I can feel the effect.
Note though, It doesn't appear to cause me to lag, only slow down.
Any insights would be greatly appreciated, and I will post code if needed, but currently.. I have no idea what code would be relevant!
When you say it slows down, you mean your frame rate drops? Sounds like your snowman is very polygon heavy, when it's being rendered it causes a drop in frame rate slowing things down.
When you're facing away from the snowman it's being clipped, it's not in view so the polygons comprising the model aren't being sent all the way through the 3D pipeline.
If you don't have back face culling turned on, you'll probably want to do that — otherwise you probably need to simplify the model somewhat. What happens if you render a cube there instead?
Depending on what hardware you're using, even a low poly model could cause problems if you don't have a huge fill rate (the speed of the hardware to fill pixels in the render buffer), but given that it's one model and that the hardware should be more than capable of filling the screen once, I'd say this is an unlikely scenario.

box2d + cocos2d: Why is there a delay when manipulating objects in box 2d using mouseJoint

When I drag an object in my game, the object is never directly under the finger. There us this lag / delay that I cannot get rid of. It follows my finger instead of being directly underneath it. You can try in the Testbed as well. Trying moving an object really fast and the object is never underneath the mouse/finger
Is this a weakness in box2d? Or am I missing something obvious ?
Thanks in advance
That's because mouseJoint is similar to distantJoint (spring). There is a maxForce parameter you can specify to minimize the delay - make the spring more hard.
EDIT:
Also you can move your object directly specifying it's position to your finger position. But if this object will collide with something it will provide non-physical behavior because the velocity of the body will be zero.
So to move it correctly (if there will be collisions) you should specify it's velocity or acceleration (as mouse joint does). But to evaluate your finger velocity you will need some time and delay will remain.
Most of it has to do with latency in the hardware. If your timings are completely perfect, their will be 16ms of lag caused by the iPhone's GPU, ~20ms of lag from the touchscreen, and then how ever long the processing takes for your scene. So those add up to anywhere between 36-70ms of lag. Also, there is a small amount of damping applied in box2d on the mouse joint, for stability of the physics simulation.

Mouse coordinates lags if CPU usage is not 100% - really weird!

When i make my program to use only 0-2% cpu (removed some CPU intensive opengl function), my mouse coordinates starts to lag! and when i use 100% CPU (when enabling the opengl function) i get nice and smooth mouse coordinates, note that the opengl function does nothing to my mouse coordinates. look at below image i recorded my rotation function values by using mouse coordinates:
This is with 100% cpu usage (as it should look):
no lag http://img15.imageshack.us/img15/1304/mousecursorsmoothcoords.png
-
This is with 2% cpu usage:
lag http://img5.imageshack.us/img5/5514/mousecursorlaggedcoords.png
It is really annoying problem, because i am using mouse cursor position to change the rotation angle, and with the above image case, it looks really laggy rotation.
I might be able to make own interpolation or something, but i want to know what is causing this and how to fix it.
Im getting mouse coordinates with WM_MOUSEMOVE message and i also tried to use GetCursorPos() on every frame before my rotation code, but it has no difference.
Edit: I noticed that the CPU usage doesnt have to be 100% to get smooth, but the CPU just needs to be "waken up" and then it stays smooth even with low CPU usage.
Your second graph seems like it is "bunching" updates. Jumps on the Y axis seem to be at a fixed frequency on the X axis.
Speculation:
Maybe power saving is kicking your CPU to/from a lower power state. Is this a laptop, or is CPU power saving enabled in Windows/BIOS (I'm not sure where the setting is)?
As GMan suggested in his comment, maybe it has to do with how many timeslices your app is getting
Some sort of sleep/timer functionality is regressing to a lower resolution. An example would be the difference between timeGetTime() and queryPerformanceCounter():
http://www.geisswerks.com/ryan/FAQS/timing.html
You might be able to get better information about the mouse motion by using the GetMouseMovePointsEx() API.
Sidenote: for some reason I can only see your first graphic