point

Find the center point of an object in a black-white image using C++ opencv

孤人 提交于 2019-12-13 01:13:51
问题 I have the image below. My aim is to find x,y values of the center point of the object. I tried Image moments but I couldn't find any x,y values. How can I do that? The center point shoud be the red point or something close to it. 回答1: In the link you posted, you can find the center of the image here: /// Get the mass centers: vector<Point2f> mc( contours.size() ); for( int i = 0; i < contours.size(); i++ ) { mc[i] = Point2f( mu[i].m10/mu[i].m00 , mu[i].m01/mu[i].m00 ); } You can find the

Java - Point on line

狂风中的少年 提交于 2019-12-12 20:09:52
问题 How can i find out if a Point(x,y) is on a the Line created between two other Points? I tried this but something seems to be wrong, as i don't get the results i should. public boolean intersects(Point k, Point z, Point p) { Line2D line = new Line2D.Float(k.x, k.y, z.x, z.y); if (line.ptLineDist(p) == 0) { return true; } else { return false; } } 回答1: Try this, taking Hovercraft's note about floating point numbers' imprecision into account. public boolean intersects(Point k, Point z, Point p) {

How can I find the points in a line - Objective c?

僤鯓⒐⒋嵵緔 提交于 2019-12-12 20:04:58
问题 Consider a line from point A (x,y) to B (p,q). The method CGContextMoveToPoint(context, x, y); moves to the point x,y and the method CGContextAddLineToPoint(context, p, q); will draw the line from point A to B. My question is, can I find the all points that the line cover? Actually I need to know the exact point which is x points before the end point B. Refer this image.. The line above is just for reference. This line may have in any angle. I needed the 5th point which is in the line before

Getting Coordinates of a Point in a circle

一笑奈何 提交于 2019-12-12 15:16:13
问题 so I have written a class which draws me a Circle. I obviously know the radius and the center coordinates of the circle. Let's say I want to draw a Point with a distance to the center equal to the half of the radius (r*0.5) and with an angle of 59 degrees. How can I draw the Point at the correct x and y coordinates? I coded this in Android, but I think the programming language isn't relevant for this problem, it's just something mathematical. I appreciate your help. 回答1: x = r * cos(A) + x0;

Why can't this code produce a points layer in GeoTools

て烟熏妆下的殇ゞ 提交于 2019-12-12 06:17:21
问题 I am testing adding a collection of points to a map utilizing the Geotools API. I've been following this example as best I could Problem creating a point and adding it to FeatureCollection, as the example code is old, and things like FeatureCollections is deprecated. I tried using DefaultFeatureCollection instance instead, and I am not sure if I am using it correctly, and that is why the points do not appear on the map. What am I doing wrong? Here is some of my code: private void plotMarkers(

Can't get a CCPointArray to work in Cocos2D-x

和自甴很熟 提交于 2019-12-12 04:33:44
问题 I want to create a an array of points (_grid). However, I can't seem to use this CCPointArray anywhere except the function it's created in. I've tried making it public in my class and declaring it in my header, but all fail. Any tips? 回答1: after CCPointArray* p = CCPointArray::create(8); did you call p->retain(); ? and remember to release it in your destructor or onExit(); in your YOUR_CLASS.h file class YOUR_CLASS : public cocos2d::CCLayer { CCPointArray* p; public: CREATE_FUNC(YOUR_CLASS);

Can a Pen or Brush paint a Point?

安稳与你 提交于 2019-12-12 04:09:51
问题 I know that I can draw a filled circle and I can draw many simple and complicated things with a Graphics. But I couldn't get it to draw a single point (not a single pixel). I'm playing with a Paint program and the user can draw fine but not plot a dot. I can add a dummy point really close or can draw a filled cirlce but sometimes I miss the obvious. So is there a way to draw a single point with a given Brush or Pen ? And no, of course I don't mean to draw a single Pixel. I want to use the

Getting mount point when a USB device is inserted Mac OS X and linux

强颜欢笑 提交于 2019-12-12 03:09:30
问题 I am trying to develop a program in Mac OS and Linux which lists the files and folders in USB drive. I need to get the some events when USB device is connected and removed. I know that in Mac OS X I can use IOKit. But I do n't know how to get the mount point where the device is mounted. Can I get it using IOkit? Is there any cross platform solution for Linux and Mac? 回答1: No, there isn't. Under Linux you may use HAL or DeviceKit-disks D-Bus interfaces. Note those are optional components and

the method of calculate the GLCM of a specific point in a image

て烟熏妆下的殇ゞ 提交于 2019-12-12 02:46:50
问题 As we know, GLCM (Grey Level Co-occurrence Matrix) describes the texture characteristics of images. But in usual, the calculation of GLCM in OpenCV, matlab often aim on a picture. But now I just want to get GLCM value of every single point inside the image, but how to get it? 回答1: If I understand your problem correctly, then perhaps you can just set the pixels outside your region of interest to NaN - these pixels are ignored by MATLAB when calculating the GLCM. For example: >> im = eye(7) im

find closest point to mouse position

血红的双手。 提交于 2019-12-12 01:59:34
问题 I've got a grid of sprites. Now I would like to drag an image on a grid-element. Therefore I need to know which x/y of the grid-element is the closest point to the mouse-position. All the grid-elements are stored in an array. How can I achieve that? 回答1: If all you need is the x,y of the closest grid then all you have to do is. var gridX:int = Math.floor(mouseX / NumberOfColumns); var gridY:int = Math.floor(mouseY / NumberOfRows); This will convert your mouse coordinates to your grid