Search Results

Search found 1655 results on 67 pages for 'detection'.

Page 6/67 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Rails Browser Detection Methods

    - by alvincrespo
    Hey Everyone, I was wondering what methods are standard within the industry to do browser detection in Rails? Is there a gem, library or sample code somewhere that can help determine the browser and apply a class or id to the body element of the (X)HTML? Thanks, I'm just wondering what everyone uses and whether there is accepted method of doing this? I know that we can get the user.agent and parse that string, but I'm not sure if that is that is an acceptable way to do browser detection. Also, I'm not trying to debate feature detection here, I've read multiple answers for that on StackOverflow, all I'm asking for is what you guys have done. [UPDATE] So thanks to faunzy on GitHub, I've sort of understand a bit about checking the user agent in Rails, but still not sure if this is the best way to go about it in Rails 3. But here is what I've gotten so far: def users_browser user_agent = request.env['HTTP_USER_AGENT'].downcase @users_browser ||= begin if user_agent.index('msie') && !user_agent.index('opera') && !user_agent.index('webtv') 'ie'+user_agent[user_agent.index('msie')+5].chr elsif user_agent.index('gecko/') 'gecko' elsif user_agent.index('opera') 'opera' elsif user_agent.index('konqueror') 'konqueror' elsif user_agent.index('ipod') 'ipod' elsif user_agent.index('ipad') 'ipad' elsif user_agent.index('iphone') 'iphone' elsif user_agent.index('chrome/') 'chrome' elsif user_agent.index('applewebkit/') 'safari' elsif user_agent.index('googlebot/') 'googlebot' elsif user_agent.index('msnbot') 'msnbot' elsif user_agent.index('yahoo! slurp') 'yahoobot' #Everything thinks it's mozilla, so this goes last elsif user_agent.index('mozilla/') 'gecko' else 'unknown' end end return @users_browser end

    Read the article

  • What datastructure would you use for a collision-detection in a tilemap?

    - by Solom
    Currently I save those blocks in my map that could be colliding with the player in a HashMap (Vector2, Block). So the Vector2 represents the coordinates of the blog. Whenever the player moves I then iterate over all these Blocks (that are in a specific range around the player) and check if a collision happened. This was my first rough idea on how to implement the collision-detection. Currently if the player moves I put more and more blocks in the HashMap until a specific "upper bound", then I clear it and start over. I was fully aware that it was not the brightest solution for the problem, but as said, it was a rough first implementation (I'm still learning a lot about game-design and the data-structure). What data-structure would you use to save the Blocks? I thought about a Queue or even a Stack, but I'm not sure, hence I ask.

    Read the article

  • Breakout clone, how to handle/design for collision detection/physics between objects?

    - by Zolomon
    I'm working on a breakout clone, and I wish to create some realistic physics effects for collision - angles on the paddle should allow the ball to bounce, as well as doing curve balls etc. I could use per-pixel based collision detection, but then I thought it might be easier with line/circle intersection testing. So, then I naturally consider making a polygon class for the line-based objects and use the built-in circle class for the circular objects. That sounds like an OK approach, right? And then just check for collision using the specified algorithm based on the objects that might be within each other's range?

    Read the article

  • What collision detection approach for top down car game?

    - by nathan
    I have a quite advanced top down car game and i use masks to detect collisions. I have the actual designed track (what the player see) with fancy graphics etc. and two other pictures i use as mask for my detection collisions. Each mask has only two colors, white and black and i check each frame if a pixel of the car collide with a black pixel of the masks. This approach works of course but it's not really flexible. Whenever i want to change the look of a track, i have to redraw the mask and it's a real pain. What is the general approach for this kind of game? How can i improve the flexibility of such a mask based approach?

    Read the article

  • Is there a good way to get pixel-perfect collision detection in XNA?

    - by ashes999
    Is there a well-known way (or perhaps reusable bit of code) for pixel-perfect collision detection in XNA? I assume this would also use polygons (boxes/triangles/circles) for a first-pass, quick-test for collisions, and if that test indicated a collision, it would then search for a per-pixel collision. This can be complicated, because we have to account for scale, rotation, and transparency. WARNING: If you're using the sample code from the link from the answer below, be aware that the scaling of the matrix is commented out for good reason. You don't need to uncomment it out to get scaling to work.

    Read the article

  • How can i get almost pixel perfect collision detection in a multiplayer game?

    - by Freddy
    I'm currently working on a multiplayer game for iPhone. The problem i have, as with all multiplayer games, is that the other user will always see everything at a non-constant delay. The game I'm making need to have a almost pixel perfect collision detection, but 1 or 2 pixels off is not that big of a deal. How can I possibly get this working? I guess I could just set local player to also be at X ms delay. However this will probably just be worse and feel sloppy when the user input. I know this problem is probably something network programmers deal with everyday and I would be glad if someone could give me a possible solution for this.

    Read the article

  • Would it be more efficient to handle 2D collision detection with polygons, rather than both squares/polygons?

    - by KleptoKat
    I'm working on a 2D game engine and I'm trying to get collision detection as efficient as possible. One thing I've noted is that I have a Rectangle Collision collider, a Shape (polygon) collider and a circle collider. Would it be more efficient (either dev-time wise or runtime wise) to have just one shape collider, rather than have that and everything else? I feel it would optimize my code in the back end, but how much would it affect my game at runtime? Should I be concerned with this at all, as 3D games generally have tens of thousands of polygons?

    Read the article

  • Sub Rectangle or ROI problem in opencv

    - by iva123
    Hi, I'm trying to convert this c code(http://nashruddin.com/OpenCV_Eye_Detection) to the python code, but in c style, he used cvROI thing, since ROI functions are not supported by python-opencv, I tried cvGetSubRect so Here is the eye detection part of the code : eye_region = cvGetSubRect(image,cvRect(face.x,int(face.y + (face.height/4)),face.width,int(face.height/2))) eyes = cvHaarDetectObjects(eye_region,eyeCascade,memo,1.15,3,0,cvSize(25,15)) for e in eyes: cvRectangle(image, cvPoint( int(e.x), int(e.y)), cvPoint(int(e.x + e.width), int(e.y + e.height)), CV_RGB(0, 255, 0), 1, 8, 0) return image; When I run this code, It draws rectangles irrelevant places. I thought, eye_region coordinates are wrong, and tried some coordinates, but it didn't work. Any idea ? Note :Face detection method works very well, and it's code is same with the eye detection method.

    Read the article

  • Collision Detection - Java - Rectangle

    - by Trizicus
    I would like to know if this is a good idea that conforms to best practices that does not lead to obscenely confusing code or major performance hit(s): Make my own Collision detection class that extends Rectangle class. Then when instantiating that object doing something such as Collision col = new Rectangle(); <- Should I do that or is that something that should be avoided? I am aware that I 'can' but should I? I want to extend Rectangle class because of the contains() and intersects() methods; should I be doing that or should I be doing something else for 2D collision detection in Java?

    Read the article

  • Adaboost algorithm and its usage in face detection

    - by Hani
    I am trying to understand Adaboost algorithm but i have some troubles. After reading about Adaboost i realized that it is a classification algorithm(somehow like neural network). But i could not know how the weak classifiers are chosen (i think they are haar-like features for face detection) and how finally the H result which is the final strong classifier can be used. I mean if i found the alpha values and compute the H ,how am i going to benefit from it as a value (one or zero) for new images. Please is there an example describes it in a perfect way? i found the plus and minus example that is found in most adaboost tutorials but i did not know how exactly hi is chosen and how to adopt the same concept on face detection. I read many papers and i had many ideas but until now my ideas are not well arranged. Thanks....

    Read the article

  • What is better: CSS hacks or browser detection?

    - by Darryl Hein
    Commonly when I look around the Internet, I find that people are generally using CSS hacks to make their website look the same in all browsers. Personally, I have found this to be quite time consuming to find all of these hacks and test them; each change you make you have to test in 4+ browsers to make sure it didn't break anything else. About a year ago, I looked around the Internet for what other major sites are using (Yahoo, Google, BBC, etc) and found that most of them are doing some form of browser detection (JS, HTML if statements, server based). I have started doing this as well. On almost all of the sites I have worked on recently, I use jQuery, so I use the built in browser detection. Is there a reason you use or don't use either of these?

    Read the article

  • Where should I place my reaction code in Per-Pixel Collision Detection?

    - by CJ Cohorst
    I have this collision detection code: public bool PerPixelCollision(Player player, Game1 dog) { Matrix atob = player.Transform * Matrix.Invert(dog.Transform); Vector2 stepX = Vector2.TransformNormal(Vector2.UnitX, atob); Vector2 stepY = Vector2.TransformNormal(Vector2.UnitY, atob); Vector2 iBPos = Vector2.Transform(Vector2.Zero, atob); for(int deltax = 0; deltax < player.playerTexture.Width; deltax++) { Vector2 bpos = iBPos; for (int deltay = 0; deltay < player.playerTexture.Height; deltay++) { int bx = (int)bpos.X; int by = (int)bpos.Y; if (bx >= 0 && bx < dog.dogTexture.Width && by >= 0 && by < dog.dogTexture.Height) { if (player.TextureData[deltax + deltay * player.playerTexture.Width].A > 150 && dog.TextureData[bx + by * dog.Texture.Width].A > 150) { return true; } } bpos += stepY; } iBPos += stepX; } return false; } What I want to know is where to put in the code where something happens. For example, I want to put in player.playerPosition.X -= 200 just as a test, but I don't know where to put it. I tried putting it under the return true and above it, but under it, it said unreachable code, and above it nothing happened. I also tried putting it by bpos += stepY; but that didn't work either. Where do I put the code?

    Read the article

  • Huge dataset point in polygon in .net (collision detection)

    - by Rickard Liljeberg
    I have a pretty big mesh with polygons, usually triangles but sometimes rectangles. Each point in my mesh has a value (value has nothing to do with coordinates). Now I am creating a second mesh in the same coordinate-space as the old mesh. I now want to interpolate out values for all points (vertices) in the new mesh using the values from the old mesh. Now I could loop each polygon in the new mesh and detect which old vertices are in each polygon by making 2d collision detection (altho even this I don't get to function properly so if anyone has simple and fast code for 2d collision detection (triangle is enough) I would gladly see it). However to my main point again. looping each old vertice for each new polygon seems less than efficient. is there a better way?

    Read the article

  • How to choose cell to put entity in in an uniform grid used for broad phase collision detection?

    - by nathan
    I'm trying to implement the broad phase of my collision detection algorithm. My game is an arcade game with lot of moving entities in an open space with relatively equivalent sizes. Regarding the above specifications, i decided to use an uniform grid for space partitioning. The problem i have right know is how to efficiently choose in which cells an entity should be added. ATM i'm doing something like this: for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { GridCell cell = grid[x][y]; cell.clear(); //remove the previously added entities for (int i = 0; i < entities.size(); i++) { Entity e = entities.get(i); if (cell.isEntityOverlap(e)) { cell.add(e); } } } } The isEntityOverlap is a simple method i added my GridCell class. public boolean isEntityOverlap(Shape s) { return cellArea.intersects(s); } Where cellArea is a Rectangle. cellArea = new Rectangle(x, y, CollisionGrid.CELL_SIZE, CollisionGrid.CELL_SIZE); It works but it's damn slow. What would be a fast way to know all the cells an entity overlaps? Note: by "it works" i mean, the entities are contained in the good cells over the time after movements etc.

    Read the article

  • Using CGRectIntersectsRect for collision detection

    - by user309030
    Hi guys, I've got a long rectangular image which is rotated at different kind of angles. However the frame of the rectangular image does not rotate along with the image and instead, the rotation causes the frame to to become larger to fit the rotated image. So when I used CGRectIntersectsRect, the collision detection is totally off because the other image colliding with the rectangular image will collide before it even reaches the visible area of the rect image. In case you don't really know what I'm talking about, have a look at the ascii drawing: normal rectangular image frame, O - pixels, |, – - frame |----------| |OOOOOOOOOO| |----------| after rotation |----------| |O | | O | | O | | O | | O | | O | | O | | O | | O | |----------| I've read through some of the collision articles but all of them are talking about collision with a normal straight rectangle and what I really want is collision with a slanted image, preferably pixel collision detection. TIA for any suggestions made.

    Read the article

  • Opinions on collision detection objects with a moving scene

    - by Evan Teran
    So my question is simple, and I guess it boils down to how anal you want to be about collision detection. To keep things simple, lets assume we're talking about 2D sprites defined by a bounding box. In addition, let's assume that my sprite object has a function to detect collisions like this: S.collidesWith(other); Finally the scene is moving and "walls" in the scene can move, an object may not touch a wall. So a simple implementation might look like this (psuedo code): moveWalls(); moveSprite(); foreach(wall as w) { if(s.collidesWith(w)) { gameover(); } } The problem with this is that if the sprite and wall move towards each other, depending on the circumstances (such as diagonal moment). They may pass though each other (unlikely but could happen). So I may do this instead. moveWalls(); foreach(wall as w) { if(s.collidesWith(w)) { gameover(); } } moveSprite(); foreach(wall as w) { if(s.collidesWith(w)) { gameover(); } } This takes care of the passing through each other issue, but another rare issue comes up. If they are adjacent to each other (literally the next pixel) and both the wall and the sprite are moving left, then I will get an invalid collision since the wall moves, checks for collision (hit) then the sprite is moved. Which seems unfair. In addition, to that, the redundant collision detection feels very inefficient. I could give the player movement priority alleviating the first issue but it is still checking twice. moveSprite(); foreach(wall as w) { if(s.collidesWith(w)) { gameover(); } } moveWalls(); foreach(wall as w) { if(s.collidesWith(w)) { gameover(); } } Am I simply over thinking this issue, should this just be chalked up to "it'll happen rare enough that no one will care"? Certainly looking at old sprite based games, I often find situations where the collision detection has subtle flaws, but I figure by now we can do better :-P. What are people's thoughts?

    Read the article

  • Collision detection by sliding against a plane in XNA

    - by Bevin
    Hello, I am attempting to engineer a collision detection algorithm for a custom Minecraft client I'm making. Basically, the entire world is made up of cubes, and the player (or camera) needs to be able to stand on and move against these cubes. The result I want is illustrated in this image: The green line is the player's movement vector. When the player is brushing up against a plane of one of the cubes, I want the vector to change to one that is perpendicular with the plane. The vector should, however, keep all of it's velocity in the plane's direction, yet lose all velocity towards the plane. I hope I've made my question clear. What is the best and most efficient way to implement a collision detection system like this? Also, will a system like this allow for a simple gravity component?

    Read the article

  • how to keep display tick rate steady when using continuous collision detection?

    - by nas Ns
    (I've just found about this forum). I hope it is ok to repost my question again here. I posted this question at stackoverflow, but it looks like I might get better help here. Here is the question: I've implemented basic particles motion simulation with continuous collision detection. But there is small issue in display. Assume simple case of circles moving inside square. All elastic collisions. no firction. All motion is constant speed. No forces are involved, no gravity. So when a particle is moving, it is always moving at constant speed (in between collisions) What I do now is this: Let the simulation time step be 1 second (for example). This is the time step simulation is advanced before displaying the new state (unless there is a collision sooner than this). At start of each time step, time for the next collision between any particles or a particle with a wall is determined. Call this the TOC time; let’s say TOC was .5 seconds in this case. Since TOC is smaller than the standard time step, then the system is moved by TOC and the new system is displayed so that the new display shows any collisions as just taking place (say 2 circles just touched each other’s, or a circle just touched a wall) Next, the collision(s) are resolved (i.e. speeds updated, changed directions etc..). A new step is started. The same thing happens. Now assume there is no collision detected within the next 1 second (those 2 circles above will not be in collision any more, even though they are still touching, due to their speeds showing they are moving apart now), Hence, simulation time is advanced now by the full one second, the standard time step, and particles are moved on the screen using 1 second simulation time and new display is shown. You see what has just happened: One frame ran for .5 seconds, but the next frame runs for 1 second, may be the 3rd frame is displayed after 2 seconds, may be the 4th frame is displayed after 2.8 seconds (because TOC was .8 seconds then) and so on. What happens is that the motion of a particle on the screen appears to speed up or slow down, even though it is moving at constant speed and was not even involved in a collision. i.e. Looking at one particle on its own, I see it suddenly speeding up or slowing down, becuase another particle had hit a wall. This is because the display tick is not uniform. i.e. the frame rate update is changing, giving the false illusion that a particle is moving at non-constant speed while in fact it is moving at constant speed. The motion on the screen is not smooth, since the screen is not updating at constant rate. I am not able to figure how to fix this. If I want to show 2 particles at the moment of the collision, I must draw the screen at different times. Drawing the screen always at the same tick interval, results in seeing 2 particles before the collision, and then after the collision, and not just when they colliding, which looked bad when I tried it. So, how do real games handle this issue? How to display things in order to show collisions when it happen, yet keep the display tick constant? These 2 requirements seem to contradict each other’s.

    Read the article

  • Facial recognition/detection PHP or software for photo and video galleries

    - by Peter
    I have a very large photo gallery with thousands of similar people, objects, locations, things. The majority of the people in the photos have their own user accounts and avatar photos to match. There are also logical short lists of people potentially in the photo based on additional data available for each photo. I allow users to tag photos with their friends and people they know but an automated process would be better. I've used photo tagger/finder from face.com integrating with Facebook photos and the Google Picasa photo tagger for personal albums also does the same thing and is exactly what I'm looking to do. Is there a PHP script, API for Google Picasa, face.com or other recognition service or any other open source project that provides server-side facial recognition and/or grouping photos by similarity? Examples: As you can see, various photo sharing sites offer the feature, but are there any that provide an API for images stored on my own server or something extensive enough to link into my own gallery and tagging system? viewdle - Face recognition/Tagging for video PHP - Face detection in pure PHP Xarg OpenCV Face.com - app for finding and tagging photos in Facebook Google Picasa - photo sharing TeraSnaps - photo sharing site Google Portrait - photo grouping from Google Image results FaceOnIt - Video face recognition PittPatt - Detection, Recognition, Video Face Mining BetaFace ChaosFace - Real-time Face Detector

    Read the article

  • Android - How to approach fall detection algorithm

    - by bobby123
    I want to be able to feature a fairly simple fall detection algorithm in my application. At the moment in onSensorChanged(), I am getting the absolute value of the current x,x,z values and subtracting SensorManager.GRAVITY_EARTH (9.8 m/s) from this. The resulting value has to be bigger than a threshold value 10 times in a row to set a flag saying a fall has been detected by the accelerometer, the threshold value is about 8m/s. Also I'm comparing the orientation of the phone as soon as the threshold has been passed and the orienation of it when the threshold is no longer being passed, this sets another flag saying the orientation sensor has detected a fall. When both flags are set, an event occurs to check is user ok, etc etc. My problem is with the threshold, when the phone is held straight up the absolute value of accelerometer is about 9.8 m/s, but when i hold it still at an angle it can be over 15m/s. This is causing other events to trigger the fall detection, and if i increase the threshold to avoid that, it won't detect falls. Can anyone give me some advice here with what possible values i should use or how to even improve my method? Many thanks.

    Read the article

  • Java2D Distance Collision Detection

    - by Trizicus
    My current setup is only useful once collision has been made; obviously there has to be something better than this? public boolean CollisionCheck(Rectangle rect1, Rectangle rect2) { if(rect1.intersects(rect2)) { return true; } return false; } How can I do preemptive collision detection?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >