Method and system for demonstrating function of vehicle-mounted heads up display, and computer-readable storage medium
Method and system for demonstrating a function of a vehicle-mounted heads up display are disclosed. The method includes setting a projection region for displaying a first image, obtaining relative position and relative size relationships between the projection region and the virtual display region, projecting the first image in the projection region, capturing a second image of the first image, generating a virtual recognition region in the second image, determining whether an object in the second image is located within the virtual recognition region, and determining, in a case that the object is located within the virtual recognition region, a first position of the object within the virtual recognition region, determining, based on the first position, a display position of a virtual marker representative of the object within the virtual display region, and displaying the virtual marker at the display position within the virtual display region.
1. A method for demonstrating a function of a vehicle-mounted heads up display, the method comprising:
setting a projection region for displaying a first image, wherein the projection region overlaps a virtual display region of the vehicle-mounted heads up display;
obtaining relative position and relative size relationships between the projection region and the virtual display region;
projecting the first image in the projection region, the first image comprising one or more objects to be marked in the virtual display region;
capturing a second image, wherein the second image is an image of the projection region containing the first image;
generating a virtual recognition region in the second image based on the relative position and relative size relationships;
determining whether an object in the second image is located within the virtual recognition region, and determining, in a case that the object is located within the virtual recognition region, a first position of the object within the virtual recognition region;
determining, based on the first position, a display position of a virtual marker representative of the object within the virtual display region; and
displaying the virtual marker at the display position within the virtual display region,
wherein generating the virtual recognition region in the second image comprises:
making relative position and relative size relationships between the second image and the virtual recognition region to be the same as the relative position and relative size relationships between the projection region and the virtual display region,
wherein shapes of the projection region and the virtual display region are rectangles, wherein a bottom edge of the projection region coincides with a bottom edge of the virtual display region, wherein a center of the bottom edge of the projection region coincides with a center of the bottom edge of the virtual display region, and wherein obtaining the relative position and relative size relationships between the projection region and the virtual display region comprises:
establishing a first coordinate system such that an abscissa axis of the first coordinate system coincides with the bottom edge of the projection region, and an ordinate axis of the first coordinate system passes through the center of the bottom edge of the projection region;
respectively determining coordinates of a first endpoint and a second endpoint of a top edge of the projection region in the first coordinate system;
respectively determining coordinates of a third endpoint and a fourth endpoint of a top edge of the virtual display region in the first coordinate system; and
determining a ratio r1 of a length of the top edge of the projection region to a length of the top edge of the virtual display region and a ratio r2 of a length of a side edge of the projection region to a length of a side edge of the virtual display region,
wherein the coordinates of the third endpoint and the fourth endpoint of the top edge of the virtual display region are as follows:
X C =−s *tan(α/2), Y C =2 s *tan(β/2); and
X D =s *tan(α/2), Y D =2 s *tan(β/2);
wherein X C and Y C respectively represent an abscissa and an ordinate of the third endpoint, X D and Y D respectively represent an abscissa and an ordinate of the fourth endpoint, s represents a distance from a view window center of the vehicle-mounted heads up display to the projection region, and α and β respectively represent a horizontal angle of view and a vertical angle of view of the vehicle-mounted heads up display.
2. The method according to claim 1 , wherein generating the virtual recognition region in the second image comprises:
establishing a second coordinate system such that an abscissa axis of the second coordinate system coincides with a bottom edge of the second image, and an ordinate axis of the second coordinate system passes through a center of the bottom edge of the second image;
determining a pixel distance d1 between two endpoints of a top edge of the second image and a pixel distance d2 between two endpoints of a side edge of the second image; and
defining a length of a top edge of the virtual recognition region as d1/r1 and defining a length of a side edge of the virtual recognition region as d2/r2, such that coordinates of two endpoints of the top edge of the virtual recognition region in the second coordinate system are (−d1/2r1, d2/r2) and (d1/2r1, d2/r2) respectively, and coordinates of two endpoints of a bottom edge of the virtual recognition region in the second coordinate system are (−d1/2r1, 0) and (d1/2r1, 0) respectively.
3. The method according to claim 2 , wherein a ratio of an abscissa of the display position of the virtual marker in the virtual display region in the first coordinate system to the top edge of the virtual display region is equal to a ratio of an abscissa of the first position in the second coordinate system to the top edge of the virtual recognition region, and wherein a ratio of an ordinate of the display position of the virtual marker in the virtual display region in the first coordinate system to the side edge of the virtual display region is equal to a ratio of an ordinate of the first position in the second coordinate system to the side edge of the virtual recognition region.
4. The method according to claim 1 , wherein the first image is an image displaying a road condition.
5. The method according to claim 4 , wherein the object comprises at least one of a vehicle, a pedestrian, or a guidepost.
6. A non-transitory computer-readable storage medium, storing a computer program code, wherein the computer program code, when executed by a processor, carries out steps of the method for demonstrating the function of the vehicle-mounted heads up display according to claim 1 .
7. A system for demonstrating a function of a vehicle-mounted heads up display, the system comprising:
at least one processor; and
at least one memory storing a computer program code;
wherein the computer program code, when executed by the at least one processor, enables the system to:
set a projection region for displaying a first image, wherein the projection region overlaps a virtual display region of the vehicle-mounted heads up display;
obtain relative position and relative size relationships between the projection region and the virtual display region;
project the first image in the projection region, the first image comprising one or more objects to be marked in the virtual display region;
capture a second image, wherein the second image is an image of the projection region containing the first image;
generate a virtual recognition region in the second image based on the relative position and relative size relationships;
determine whether an object in the second image is located within the virtual recognition region, and determine, in a case that the object is located within the virtual recognition region, a first position of the object within the virtual recognition region;
determine, based on the first position, a display position of a virtual marker representative of the object within the virtual display region; and
display the virtual marker at the display position within the virtual display region,
wherein the computer program code, when executed by the at least one processor, enables the system to generate the virtual recognition region in the second image by:
making relative position and relative size relationships between the second image and the virtual recognition region to be the same as the relative position and relative size relationships between the projection region and the virtual display region,
wherein shapes of the projection region and the virtual display region are rectangles, wherein a bottom edge of the projection region coincides with a bottom edge of the virtual display region, and wherein a center of the bottom edge of the projection region coincides with a center of the bottom edge of the virtual display region,
wherein the computer program code, when executed by the at least one processor, enables the system to obtain the relative position and relative size relationships between the projection region and the virtual display region by:
establishing a first coordinate system such that an abscissa axis of the first coordinate system coincides with the bottom edge of the projection region, and an ordinate axis of the first coordinate system passes through the center of the bottom edge of the projection region;
respectively determining coordinates of a first endpoint and a second endpoint of a top edge of the projection region in the first coordinate system;
respectively determining coordinates of a third endpoint and a fourth endpoint of a top edge of the virtual display region in the first coordinate system; and
determining a ratio r1 of a length of the top edge of the projection region to a length of the top edge of the virtual display region and a ratio r2 of a length of a side edge of the projection region to a length of a side edge of the virtual display region,
wherein the coordinates of the third endpoint and the fourth endpoint of the top edge of the virtual display region are as follows:
X C =−s *tan(α/2), Y C =2 s *tan(β/2); and
X D =s *tan(α/2), Y D =2 s *tan(β/2);
wherein X C and Y C respectively represent an abscissa and an ordinate of the third endpoint, X D and Y D respectively represent an abscissa and an ordinate of the fourth endpoint, s represents a distance from a view window center of the vehicle-mounted heads up display to the projection region, and α and β respectively represent a horizontal angle of view and a vertical angle of view of the vehicle-mounted heads up display.
8. The system according to claim 7 , wherein the computer program code, when executed by the at least one processor, enables the system to generate the virtual recognition region in the second image by:
establishing a second coordinate system such that an abscissa axis of the second coordinate system coincides with a bottom edge of the second image, and an ordinate axis of the second coordinate system passes through a center of the bottom edge of the second image;
determining a pixel distance d1 between two endpoints of a top edge of the second image and a pixel distance d2 between two endpoints of a side edge of the second image; and
defining a length of a top edge of the virtual recognition region as d1/r1 and defining a length of a side edge of the virtual recognition region as d2/r2, such that coordinates of two endpoints of the top edge of the virtual recognition region in the second coordinate system are (−d1/2r1, d2/r2) and (d1/2r1, d2/r2) respectively, and coordinates of two endpoints of a bottom edge of the virtual recognition region in the second coordinate system are (−d1/2r1, 0) and (d1/2r1, 0) respectively.
9. The system according to claim 8 , wherein a ratio of an abscissa of the display position of the virtual marker in the virtual display region in the first coordinate system to the top edge of the virtual display region is equal to a ratio of an abscissa of the first position in the second coordinate system to the top edge of the virtual recognition region, and wherein a ratio of an ordinate of the display position of the virtual marker in the virtual display region in the first coordinate system to the side edge of the virtual display region is equal to a ratio of an ordinate of the first position in the second coordinate system to the side edge of the virtual recognition region.
10. The system according to claim 7 , wherein the first image is an image displaying a road condition.
11. The system according to claim 10 , wherein the object comprises at least one of a vehicle, a pedestrian, or a guidepost.