summaryrefslogtreecommitdiff
path: root/WPIJavaCV/src/edu/wpi/first/wpijavacv/WPIWindow.java
blob: f15db45398263fa20d1bc7a697660ad74581d086 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpijavacv;

import static com.googlecode.javacv.cpp.opencv_highgui.*;

/**
 * A class that can be used for displaying images
 * @author Greg Granito
 */
public class WPIWindow {

    private static int count = 0;

    private String name;

    /**
     * Creates a new window with a default name that will be in the format
     * "Window " + windowNumber
     */
    public WPIWindow() {
        count++;

        name = "Window " +count;
        cvNamedWindow(name);

    }

    /**
     * Creates a new window with the specified name must be unique
     * (including the windows named using the default constructor)
     * @param name the desired name
     */
    public WPIWindow(String name) {
        this.name = name;
    }


   /**
    * Shows the specified image, must be the same resolution and depth
    * as the first image the window shows
    * @param image the image
    */
    public void showImage(WPIImage image) {

        if(image != null)
        cvShowImage(name, image.image);
        else cvShowImage(name, null);
    }
}