The beginning of the project- ing from 2D image recognition to 3D (Java3D)

Source: Internet
Author: User

The University has only three months left, as if it has experienced another reincarnation-beginning to miss the university life. Therefore, I chose to stay in the school and complete the three months of university indulgence. After graduation, you can at least recall the last days of college.

 

Biji followed the previous lab teacher's main content: Image Recognition of the characters in the photo, and then mapped to the pre-built 3D model to detect the characters. Because this project needs to be compatible with existing projects in the laboratory, Java3D is used to operate the 3D model.

Appendix

Technology Implementation level Development Technology (difficulty) Scalability Most suitable for application fields
Java3D Middle Layer (JVM) Java (easier) J2se standard extension (good) 3D online display...
OpenGL Underlying layer (graphics card) C/C ++ (hard) Support from major vendors (better) 3D design software...
Direct3d Underlying (Operating System) C ++ (difficult) Windows platform (poor) 3D games...
Fig Upper Layer (webpage) Markup Language (easy) Install plug-in support (General) Online virtual reality...

Java3D API is a programming interface used to develop 3D graphics and web-based 3D applications (applets. Currently, 3D APIs (OpenGL and direct3d) used to develop 3D graphics software are based on the camera model idea. By adjusting camera parameters, you can control the display objects in a scenario, java3D proposes a new technology implementation solution based on the video platform's visual model and input device model, that is, browsing the entire virtual scenario by changing the position and direction of the video platform. It not only provides high-level constructors for the construction and operation of Three-dimensional Geometric objects, but also allows the use of these constructors to create virtual scenes with varying degrees of complexity. These virtual scenes are as big as cosmic objects, small to microscopic particles.

Java3D provides the following functions:

 

1). generate simple or complex shapes (you can also directly call existing 3D shapes)

2) Make the shape color, transparent effect, texture.
3). You can generate and move lights in a 3D environment.
4). Behavior processing and judgment capabilities (keyboard, mouse, timing, etc)
5). Fog, background, and sound can be generated.
6). deformation, movement, and 3D animation can be generated.
7). You can write very complex applications for various fields such as VR.

1.1 Java3D introduction:

Java3D API is an interface defined by Sun for 3D display. 3D technology is the underlying display technology. Java3D provides Java-based Upper-layer interfaces. Java3D encapsulates the underlying technologies OpenGL and DirectX in Java interfaces. This new design makes 3D technology no longer cumbersome and can be added to the entire j2se and J2EE architecture. These features ensure the powerful scalability of Java3D technology.

 

 

1.2 Java3D scene MAP Structure

 

Java3D is actually an extension of the Java language in the field of 3D graphics. Like java, Java3D has a pure object-oriented structure. The data structure of Java3D uses scene graphs structure (scene chart), which is a tree structure composed of some asymmetric images with directionality (figure 1 ). From the perspective of the program, the realistic 3D scenario we see in a Java3D application is actually a series of objects defined by Java3D. These objects are not disordered, and they are not unrelated. To enable normal display of 3D images, you must follow the Java3D scene map rules. Observe Figure 1. The structure of the Java3D scene chart consists of various objects:

 

The objects shown in the figure all implement classes of significant significance in Java3D. Logically, we divide them into three categories:

  • Root Node (Root): virtual universe object
  • Node: local object, branch group nodes, behavior node, shape3d node...
  • Leaf node (leaf): appearance, geomery ..

Figure 1: Java3D scene in applications

 

 

Node is the intersection of the midline and line in the scenario diagram. These nodes are instances of class in Java3D class, and the line between nodes indicates the relationship between instances.

  • Virtual universe is the root node, and the virtual universe of each scene graph is unique.
  • Under virtual universe is a locale node, each program can have one or more locale, but at the same time, only one locale can be displayed, as if a 3D world is very large, there are many scenic spots, but we can only observe one attraction at the same time. Java3D allows you to jump from one locale to another, but most programs only have one locale.
  • Each locale can have multiple branchgroup nodes. Transform Group nodes is created on the branchgroup node.
  • Transformgroup node is used to set the position of shape3d in virtual universe.
  • Spape3d node is a 3D image node. The entity of this node is displayed on the final display screen, which is every shape in the 3D world. Includes cubes, sphere, and any shape and appearance of three-dimensional form.
  • Two leaf nodes are located at the bottom of the scene map: the appearance of the three-dimensional object (appearance) and the geometric information (geometry). The two nodes define the Display Effect of a three-dimensional object.
  • View Platform is located on another branch of Figure 1. Unlike all previous concepts that describe the nature of a 3D object, View Platform and view are used to define the information of the observer.

There are many concepts listed above, but we need to understand at least three concepts for creating a simple Java3D program: virtual universe, scene (locale), and coordinate system.

 

 

2.1 virtual universe)

 

In Java3D, a virtual universe is defined as a three-dimensional space that combines a series of objects. The virtual universe is used as the largest aggregate expression unit and can also be seen as a database. Whether in physical space or logical content, the virtual universe can be very large. In fact, in most cases, a virtual universe can meet all the needs of an application.

The virtual universe is an independent individual, because at any time a Node object cannot exist in more than one virtual universe. Similarly, node objects in a virtual universe cannot be visible or combined with other objects in other virtual universe. For a Java3D application, a virtual universe must be defined to display 3D images in the universe.

 

2.2 Java3D Coordinate System

 

By default, the coordinate system of Java3D is right-handed. It is interpreted by azimuth semantics that the normal y direction is the local gravity, and the positive x direction is the horizontal right, Z is the direction of the observer. The default unit is meters.

Double-precision floating point, single-precision floating point, or even fixed-point 3D coordinates are enough to represent and display a wide range of 3D scenes. Unfortunately, the scene is not the real world, let alone the whole universe. If single-precision coordinates are used, the following situations may occur:

  1. It is only one hundred kilometers away from the origin, and it is depicted as a quantum number. The best result is 1 inch points per third. in actual application, such accuracy is much more rough than the requirement.
  2. If you want to narrow down to a very small size (such as the size of an integrated circuit), or even close to the origin, the same coordinate problem may occur.

To support a large adjacent virtual universe, Java3D selects a 256-bit high-resolution coordinate:

Java3D high-resolution coordinates are composed of three 256-Bit fixed points, representing X, Y, and Z respectively. The fixed point is fixed at 128th bits, and the value 1.0 is defined as a real 1 m. This coordinate system is enough to describe a universe that is more than millions of light years away. It can also be used to define objects smaller than the size of a single proton (less than a Mercury length.

In Java3D, high-resolution coordinates are only used to embed a more traditional floating-point coordinate system into a higher-resolution underlying system. Using this method, you can create a virtual universe that is visually seamless, of any size and scale, without worrying about the accuracy of the number. (See table 2)

A 256-Bit fixed point also has a single-precision floating point value that can directly represent almost any reasonable and appropriate value.

Java3D uses a signed, two-digit Fixed-Point Number of 256 to represent the coordinates of the High-score rate. Although Java3D maintains the opacity of the Internal High-Resolution coordinate representation, the user uses an array with eight Integer Variables to represent the coordinates of the 256-bit. Java3D regards the index numbers from 0 to 7 in the array as the number of high-resolution coordinates from the descending position. The decimal point of a binary number, or an integer between 3 and 4. The 1.0 of the high-resolution coordinates is 1 meter.

For a "small" virtual universe (similar to a relative proportion of several hundred meters), under a virtual universe object (0.0, 0.0, 0.0) it is enough to create a locale with high resolution coordinates as the root node. The loader can automatically build nodes during the loading process, vertices in High-Resolution coordinates do not need a direct description of any external files.

The larger virtual universe is expected to be built as a hierarchy of computer files, which means that a root universe will include an embedded virtual universe referenced by external files. In this way, the object referenced by the file (the user-specified Java3D group or high-resolution node) defines the location where the data is read into the existing virtual universe.

 

Figure 2: Use Cases with high-resolution coordinates

Java 3D high-resolution coordinates
2n meters Units
87.29 Universe (20 billion light years)
69.68 Galaxy (100000 light years)
53.07 Light year
43.43 Solar System diameter
23.60 Earth diameter
10.65 Mile
9.97 Kilometer
0.00 Meter
-19.93 Micron
-33.22 Angstrom
-115.57 Planck length

2.3 scenario (locale)

To support large virtual universe, Java3D proposed the concept of "locale. Locale uses high-resolution coordinates as the origin. The high-resolution coordinates are regarded as precise positioning. It uses floating-point coordinates with lower precision to specify the object location within the scope of the high-resolution coordinates.

A locale and high-resolution coordinates combined with it form a presentation layer under the virtual universe. All virtual universe contains one or more high-resolution locale. All other objects are attached to a locale. In the entire system, high-resolution coordinates act as upper-layer conversion nodes for translation only. For example, the coordinates of all objects appended to a specific locale are related to the high-resolution coordinates of the locale location. (Figure 2)

Figure 2: Use Cases with high-resolution coordinates

 
If a virtual universe is similar to a traditional computer image, the given virtual universe may become too large. Therefore, we recommend that you consider a scene chart as a subnode of a high-resolution coordinate scenario.

To construct a 3D scenario, a programmer must run a Java3D program. This Java3D application must first create a virtual universe object and append at least one locale object. Then, construct the desired scene image, which starts from a branch node and includes at least one observation platform object, and the scene image is attached to this observation platform. When an observed object containing a scene map is attached to a virtual universe, the rendering cycle of Java3D begins to work. In this way, the scene will be drawn on the canvas together with its observation object.
Java3D uses a signed, two-digit Fixed-Point Number of 256 to represent the coordinates of the High-score rate. Although Java3D maintains the opacity of the Internal High-Resolution coordinate representation, the user uses an array with eight Integer Variables to represent the coordinates of the 256-bit. Java3D regards the index numbers from 0 to 7 in the array as the number of high-resolution coordinates from the descending position. The decimal point of a binary number, or an integer between 3 and 4. The 1.0 of the high-resolution coordinates is 1 meter.
Suppose it's a "small" virtual universe (similar to a relative proportion of several hundred meters), under the virtual universe object (0.0, 0.0, 0.0) it is enough to create a locale with high resolution coordinates as the root node. The loader can automatically build nodes during the loading process, vertices in High-Resolution coordinates do not need a direct description of any external files.
The larger virtual universe is expected to be built as a hierarchy of computer files, which means that a root universe will include an embedded virtual universe referenced by external files. In this way, the object referenced by the file (the user-specified Java3D group or high-resolution node) defines the location where the data is read into the existing virtual universe.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.