用照片创造适合步行的NESW世界

发布于 2024-12-27 01:51:04 字数 176 浏览 3 评论 0原文

我有一组 100 张照片,拍摄于树林外 40x40 米的区域。

40x40 的区域被分为 10m 的部分,因此有 25 个拍照地点。在每个位置,面向四个罗盘位置(北、东、南、西)拍摄一张照片。

关于如何将这些照片拼接在一起,有什么建议吗?就像谷歌地图如何让你在街景中走在街上一样?

谢谢!

I have a set of 100 photos from a 40x40m area outside in the woods.

The 40x40 area was divided up into 10m sections so there are 25 locations where pictures were taken. At each location, a picture was taken facing each of the four compass locations: north, east, south, and west.

Any suggestions on how to go about stitching these photos together, sort of like how google maps lets you walk down the street in street view?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人事已非 2025-01-03 01:51:04

我会将图像存储在一个三维数组中,如下所示:

image[x][y][direction];

然后,使用按键或鼠标侦听器来更改查看器的 x 和 y 位置。因此,例如,如果您的图像在与您的类相同的目录中被命名为“0_0_N.jpg”(等),您可能会执行以下操作:

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class View {
    private static final char[] DIRECTION_NAME = { 'N', 'E', 'S', 'W' };
    private static final int[] DIRECTION_X = { 0, 1, 0, -1 };
    private static final int[] DIRECTION_Y = { 1, 0, -1, 0 };
    private static final int WIDTH = 5;
    private static final int HEIGHT = 5;

    private final JLabel label;
    private final ImageIcon[][][] images;
    private int x;
    private int y;
    private int direction;

    public View() throws IOException {
        images = new ImageIcon[WIDTH][HEIGHT][4];
        for(int x = 0; x < WIDTH; x++) {
            for(int y = 0; y < HEIGHT; y++) {
                for(int direction = 0; direction < 4; ++direction) {
                    String name = x + "_" + y + "_" + DIRECTION_NAME[direction] + ".jpg";
                    images[x][y][direction] = new ImageIcon(ImageIO.read(View.class.getResourceAsStream(name)));
                }
            }
        }

        label = new JLabel();
        label.setIcon(images[0][0][0]);

        JFrame frame = new JFrame("View");
        frame.getContentPane().add(label);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);

        label.addKeyListener(new KeyAdapter() {
            public void keyReleased(KeyEvent e) {
                switch(e.getKeyCode()) {
                case KeyEvent.VK_LEFT:
                    direction = (direction + 3) % 4;
                    break;
                case KeyEvent.VK_RIGHT:
                    direction = (direction + 1) % 4;
                    break;
                case KeyEvent.VK_UP:
                {
                    int newX = x + DIRECTION_X[direction];
                    int newY = y + DIRECTION_Y[direction];
                    if(newX >= 0 && newX < WIDTH && newY >= 0 && newY < HEIGHT) {
                        x = newX;
                        y = newY;
                    }
                    break;
                }
                }
                label.setIcon(images[x][y][direction]);
            }
        });
        label.requestFocus();
    }

    public static void main(String[] args) throws IOException {
        new View();
    }
}

I would store the images in a three-dimensional array like this:

image[x][y][direction];

Then, use a key or mouse listener to change the x and y position of the viewer. So, for example, if your images are named "0_0_N.jpg" (etc) in the same directory as your class, you might do something like this:

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class View {
    private static final char[] DIRECTION_NAME = { 'N', 'E', 'S', 'W' };
    private static final int[] DIRECTION_X = { 0, 1, 0, -1 };
    private static final int[] DIRECTION_Y = { 1, 0, -1, 0 };
    private static final int WIDTH = 5;
    private static final int HEIGHT = 5;

    private final JLabel label;
    private final ImageIcon[][][] images;
    private int x;
    private int y;
    private int direction;

    public View() throws IOException {
        images = new ImageIcon[WIDTH][HEIGHT][4];
        for(int x = 0; x < WIDTH; x++) {
            for(int y = 0; y < HEIGHT; y++) {
                for(int direction = 0; direction < 4; ++direction) {
                    String name = x + "_" + y + "_" + DIRECTION_NAME[direction] + ".jpg";
                    images[x][y][direction] = new ImageIcon(ImageIO.read(View.class.getResourceAsStream(name)));
                }
            }
        }

        label = new JLabel();
        label.setIcon(images[0][0][0]);

        JFrame frame = new JFrame("View");
        frame.getContentPane().add(label);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);

        label.addKeyListener(new KeyAdapter() {
            public void keyReleased(KeyEvent e) {
                switch(e.getKeyCode()) {
                case KeyEvent.VK_LEFT:
                    direction = (direction + 3) % 4;
                    break;
                case KeyEvent.VK_RIGHT:
                    direction = (direction + 1) % 4;
                    break;
                case KeyEvent.VK_UP:
                {
                    int newX = x + DIRECTION_X[direction];
                    int newY = y + DIRECTION_Y[direction];
                    if(newX >= 0 && newX < WIDTH && newY >= 0 && newY < HEIGHT) {
                        x = newX;
                        y = newY;
                    }
                    break;
                }
                }
                label.setIcon(images[x][y][direction]);
            }
        });
        label.requestFocus();
    }

    public static void main(String[] args) throws IOException {
        new View();
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文