affinetransform

trouble getting cv.transform to work

ぃ、小莉子 提交于 2019-12-29 08:41:29
问题 I'd like to use the same affine matrix M on some individual (x,y) points as I use on images with cv2.warpAffine. It seems cv2.transform is the way to go . When I try send an Nx2 matrix of points I get negged ( src = np.array([ [x1,y1],[x2,y2],[x3,y3],[x4,y4]], dtype = "float32") print('source shape '+str(src.shape)) dst=cv2.transform(src,M) cv2.error: /home/jeremy/sw/opencv-3.1.0/modules/core/src/matmul.cpp:1947: error: (-215) scn == m.cols || scn + 1 == m.cols in function transform I can get

trouble getting cv.transform to work

北战南征 提交于 2019-12-29 08:41:25
问题 I'd like to use the same affine matrix M on some individual (x,y) points as I use on images with cv2.warpAffine. It seems cv2.transform is the way to go . When I try send an Nx2 matrix of points I get negged ( src = np.array([ [x1,y1],[x2,y2],[x3,y3],[x4,y4]], dtype = "float32") print('source shape '+str(src.shape)) dst=cv2.transform(src,M) cv2.error: /home/jeremy/sw/opencv-3.1.0/modules/core/src/matmul.cpp:1947: error: (-215) scn == m.cols || scn + 1 == m.cols in function transform I can get

Scaling/Translating a Shape to a given Rectangle using AffineTransform

夙愿已清 提交于 2019-12-28 03:10:54
问题 I'm trying to scale/translate a java.awt. Shape with AffineTransform in order to draw it in a defined bounding Rectangle. Moreover, I want to paint it in a drawing Area having a ' zoom ' parameter. I tried various concatenations of AffineTransform but I couldn't find the correct sequence. For example, the following solution was wrong: double zoom=(...);/* current zoom */ Rectangle2D viewRect=(...)/** the rectangle where we want to paint the shape */ Shape shape=(...)/* the original shape that

How to rotate an imageIcon in Java

亡梦爱人 提交于 2019-12-24 22:01:18
问题 I'm creating a domino game in java. I have the following code that loads, resizes and then display the domino image on the screen: ImageIcon imageIcon = new ImageIcon("images\\4-4.png"); Image image = imageIcon.getImage(); Image newimg = image.getScaledInstance(60, 120, java.awt.Image.SCALE_SMOOTH); imageIcon = new ImageIcon(newimg); JLabel img = new JLabel(imageIcon); img.setBounds(100, 100, 60, 120); getContentPane().add(img); What I want to do is rotate the image either 90 or -90 degrees.

How to find out whether an affine transformed rectangle contains a certain point, in Java?

夙愿已清 提交于 2019-12-24 02:23:42
问题 I'm trying to make an interactive GUI but I need to move a certain object whenever that rectangle is clicked + dragged. Basically I wanna know whether a rectangle, that has been affine transformed, contains a specific point (x, y). Is there a way to do this? I have tried using contains() method but it doesn't work for a rectangle that has been affine transformed. I checked the Java tutorials but the user interactive GUIs don't use affine transformation. Can someone point me to a tutorial that

Matlab calculate 3D similarity transformation. fitgeotrans for 3D

时光毁灭记忆、已成空白 提交于 2019-12-23 01:19:14
问题 How can I calculate in MatLab similarity transformation between 4 points in 3D? I can calculate transform matrix from T*X = Xp , but it will give me affine matrix due to small errors in points coordinates. How can I fit that matrix to similarity one? I need something like fitgeotrans , but in 3D Thanks 回答1: The answer by @rayryeng is correct, given that you have a set of up to 3 points in a 3-dimensional space. If you need to transform m points in n-dimensional space ( m>n ), then you first

AffineTransform without transforming Stroke?

感情迁移 提交于 2019-12-22 03:20:08
问题 When using the Graphics2D scale() function with two different parameters (scaling by different ratios in x- and y-direction), everything drawn later on this Graphics2D object is scaled too. This has the strange effect that lines drawn in one direction are thicker than those in another direction. The following program produces this effect, it shows this window: public class StrokeExample extends JPanel { public void paintComponent(Graphics context) { super.paintComponent(context); Graphics2D g

JComponent JPanel Zoom, pan and Coordinates Question

旧城冷巷雨未停 提交于 2019-12-20 04:52:49
问题 I have a JPanel with an vector image that the user can zoom and pan on. Overlaying this image is a (transparent) JComponent , which I allow the user to annotate the underlying image. This works great at full scale, but If I zoom in, using AffineTransform , the overlaying coordinates are affected also. So, If a user draws a box on the image the box is scaled also. Any suggestions on how to decouple this behaviour? So that the JComponent is not affected by the JPanel 's AffineTransform ? 回答1:

findHomography, getPerspectiveTransform, & getAffineTransform

烈酒焚心 提交于 2019-12-18 10:27:58
问题 This question is on the OpenCV functions findHomography , getPerspectiveTransform & getAffineTransform What is the difference between findHomography and getPerspectiveTransform ?. My understanding from the documentation is that getPerspectiveTransform computes the transform using 4 correspondences (which is the minimum required to compute a homography/perspective transform) where as findHomography computes the transform even if you provide more than 4 correspondencies (presumably using

can't get my coordinates graphics2D mouseclick java

假如想象 提交于 2019-12-18 09:36:41
问题 I got an extended JLabel class where I draw my Map using the code below : the new AffineTransform() is the identity to left my image as it is (0,0,w,h) mygraphics2D = (Graphics2D) getGraphics(); graphics2D.scale(2.0,2.0) ; graphics2D.rotate(.... graphics2D.drawImage(myImageIcon.getImage(),new AffineTransform(), this); now when I click on my JLabel using this event : public void mouseClicked(MouseEvent e) { x =e.getX() ; y = e.getY(); NewX = ???? NewY = ???? } I want to retrieve my new