commit
bb2dc1e41e
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,187 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="159">
|
||||
<item index="0" class="java.lang.String" itemvalue="httpx" />
|
||||
<item index="1" class="java.lang.String" itemvalue="Babel" />
|
||||
<item index="2" class="java.lang.String" itemvalue="sorted-nearest" />
|
||||
<item index="3" class="java.lang.String" itemvalue="PyYAML" />
|
||||
<item index="4" class="java.lang.String" itemvalue="marshmallow" />
|
||||
<item index="5" class="java.lang.String" itemvalue="executing" />
|
||||
<item index="6" class="java.lang.String" itemvalue="fisher" />
|
||||
<item index="7" class="java.lang.String" itemvalue="gradio_client" />
|
||||
<item index="8" class="java.lang.String" itemvalue="Pygments" />
|
||||
<item index="9" class="java.lang.String" itemvalue="langchain" />
|
||||
<item index="10" class="java.lang.String" itemvalue="starlette" />
|
||||
<item index="11" class="java.lang.String" itemvalue="bleach" />
|
||||
<item index="12" class="java.lang.String" itemvalue="jupyter_server_terminals" />
|
||||
<item index="13" class="java.lang.String" itemvalue="soupsieve" />
|
||||
<item index="14" class="java.lang.String" itemvalue="uvicorn" />
|
||||
<item index="15" class="java.lang.String" itemvalue="jsonschema" />
|
||||
<item index="16" class="java.lang.String" itemvalue="terminado" />
|
||||
<item index="17" class="java.lang.String" itemvalue="comm" />
|
||||
<item index="18" class="java.lang.String" itemvalue="pydub" />
|
||||
<item index="19" class="java.lang.String" itemvalue="gunicorn" />
|
||||
<item index="20" class="java.lang.String" itemvalue="click" />
|
||||
<item index="21" class="java.lang.String" itemvalue="ipykernel" />
|
||||
<item index="22" class="java.lang.String" itemvalue="nbconvert" />
|
||||
<item index="23" class="java.lang.String" itemvalue="attrs" />
|
||||
<item index="24" class="java.lang.String" itemvalue="contourpy" />
|
||||
<item index="25" class="java.lang.String" itemvalue="psutil" />
|
||||
<item index="26" class="java.lang.String" itemvalue="dataclasses-json" />
|
||||
<item index="27" class="java.lang.String" itemvalue="jedi" />
|
||||
<item index="28" class="java.lang.String" itemvalue="openai" />
|
||||
<item index="29" class="java.lang.String" itemvalue="jupyter_server" />
|
||||
<item index="30" class="java.lang.String" itemvalue="natsort" />
|
||||
<item index="31" class="java.lang.String" itemvalue="asttokens" />
|
||||
<item index="32" class="java.lang.String" itemvalue="platformdirs" />
|
||||
<item index="33" class="java.lang.String" itemvalue="matplotlib" />
|
||||
<item index="34" class="java.lang.String" itemvalue="pandavro" />
|
||||
<item index="35" class="java.lang.String" itemvalue="jsonpatch" />
|
||||
<item index="36" class="java.lang.String" itemvalue="httpcore" />
|
||||
<item index="37" class="java.lang.String" itemvalue="referencing" />
|
||||
<item index="38" class="java.lang.String" itemvalue="json5" />
|
||||
<item index="39" class="java.lang.String" itemvalue="pyfaidx" />
|
||||
<item index="40" class="java.lang.String" itemvalue="numpy" />
|
||||
<item index="41" class="java.lang.String" itemvalue="requests" />
|
||||
<item index="42" class="java.lang.String" itemvalue="fastavro" />
|
||||
<item index="43" class="java.lang.String" itemvalue="grpcio-reflection" />
|
||||
<item index="44" class="java.lang.String" itemvalue="jupyter-events" />
|
||||
<item index="45" class="java.lang.String" itemvalue="websocket-client" />
|
||||
<item index="46" class="java.lang.String" itemvalue="sqlalchemy2-stubs" />
|
||||
<item index="47" class="java.lang.String" itemvalue="pysam" />
|
||||
<item index="48" class="java.lang.String" itemvalue="stack-data" />
|
||||
<item index="49" class="java.lang.String" itemvalue="methplotlib" />
|
||||
<item index="50" class="java.lang.String" itemvalue="zipp" />
|
||||
<item index="51" class="java.lang.String" itemvalue="nest-asyncio" />
|
||||
<item index="52" class="java.lang.String" itemvalue="tenacity" />
|
||||
<item index="53" class="java.lang.String" itemvalue="mmh3" />
|
||||
<item index="54" class="java.lang.String" itemvalue="prompt-toolkit" />
|
||||
<item index="55" class="java.lang.String" itemvalue="linkify-it-py" />
|
||||
<item index="56" class="java.lang.String" itemvalue="websockets" />
|
||||
<item index="57" class="java.lang.String" itemvalue="ipywidgets" />
|
||||
<item index="58" class="java.lang.String" itemvalue="pyarrow" />
|
||||
<item index="59" class="java.lang.String" itemvalue="watchfiles" />
|
||||
<item index="60" class="java.lang.String" itemvalue="tornado" />
|
||||
<item index="61" class="java.lang.String" itemvalue="aiofiles" />
|
||||
<item index="62" class="java.lang.String" itemvalue="jsonpointer" />
|
||||
<item index="63" class="java.lang.String" itemvalue="Send2Trash" />
|
||||
<item index="64" class="java.lang.String" itemvalue="plotly" />
|
||||
<item index="65" class="java.lang.String" itemvalue="overrides" />
|
||||
<item index="66" class="java.lang.String" itemvalue="python-multipart" />
|
||||
<item index="67" class="java.lang.String" itemvalue="toml" />
|
||||
<item index="68" class="java.lang.String" itemvalue="mistune" />
|
||||
<item index="69" class="java.lang.String" itemvalue="pandas" />
|
||||
<item index="70" class="java.lang.String" itemvalue="importlib-resources" />
|
||||
<item index="71" class="java.lang.String" itemvalue="toolz" />
|
||||
<item index="72" class="java.lang.String" itemvalue="mpmath" />
|
||||
<item index="73" class="java.lang.String" itemvalue="pyranges" />
|
||||
<item index="74" class="java.lang.String" itemvalue="debugpy" />
|
||||
<item index="75" class="java.lang.String" itemvalue="argon2-cffi" />
|
||||
<item index="76" class="java.lang.String" itemvalue="yarl" />
|
||||
<item index="77" class="java.lang.String" itemvalue="pytz" />
|
||||
<item index="78" class="java.lang.String" itemvalue="moreorless" />
|
||||
<item index="79" class="java.lang.String" itemvalue="Pillow" />
|
||||
<item index="80" class="java.lang.String" itemvalue="notebook_shim" />
|
||||
<item index="81" class="java.lang.String" itemvalue="traitlets" />
|
||||
<item index="82" class="java.lang.String" itemvalue="bowler" />
|
||||
<item index="83" class="java.lang.String" itemvalue="protobuf" />
|
||||
<item index="84" class="java.lang.String" itemvalue="rfc3339-validator" />
|
||||
<item index="85" class="java.lang.String" itemvalue="arrow" />
|
||||
<item index="86" class="java.lang.String" itemvalue="mypy" />
|
||||
<item index="87" class="java.lang.String" itemvalue="python-dotenv" />
|
||||
<item index="88" class="java.lang.String" itemvalue="nbclient" />
|
||||
<item index="89" class="java.lang.String" itemvalue="partd" />
|
||||
<item index="90" class="java.lang.String" itemvalue="MarkupSafe" />
|
||||
<item index="91" class="java.lang.String" itemvalue="locket" />
|
||||
<item index="92" class="java.lang.String" itemvalue="tinycss2" />
|
||||
<item index="93" class="java.lang.String" itemvalue="httptools" />
|
||||
<item index="94" class="java.lang.String" itemvalue="frozenlist" />
|
||||
<item index="95" class="java.lang.String" itemvalue="appdirs" />
|
||||
<item index="96" class="java.lang.String" itemvalue="python-json-logger" />
|
||||
<item index="97" class="java.lang.String" itemvalue="semantic-version" />
|
||||
<item index="98" class="java.lang.String" itemvalue="filelock" />
|
||||
<item index="99" class="java.lang.String" itemvalue="jupyterlab-widgets" />
|
||||
<item index="100" class="java.lang.String" itemvalue="pyzmq" />
|
||||
<item index="101" class="java.lang.String" itemvalue="certifi" />
|
||||
<item index="102" class="java.lang.String" itemvalue="anyio" />
|
||||
<item index="103" class="java.lang.String" itemvalue="Markdown" />
|
||||
<item index="104" class="java.lang.String" itemvalue="sympy" />
|
||||
<item index="105" class="java.lang.String" itemvalue="uvloop" />
|
||||
<item index="106" class="java.lang.String" itemvalue="notebook" />
|
||||
<item index="107" class="java.lang.String" itemvalue="beautifulsoup4" />
|
||||
<item index="108" class="java.lang.String" itemvalue="isoduration" />
|
||||
<item index="109" class="java.lang.String" itemvalue="jupyter-lsp" />
|
||||
<item index="110" class="java.lang.String" itemvalue="fqdn" />
|
||||
<item index="111" class="java.lang.String" itemvalue="jupyter_client" />
|
||||
<item index="112" class="java.lang.String" itemvalue="orjson" />
|
||||
<item index="113" class="java.lang.String" itemvalue="jupyterlab_server" />
|
||||
<item index="114" class="java.lang.String" itemvalue="altair" />
|
||||
<item index="115" class="java.lang.String" itemvalue="feast" />
|
||||
<item index="116" class="java.lang.String" itemvalue="fonttools" />
|
||||
<item index="117" class="java.lang.String" itemvalue="mdit-py-plugins" />
|
||||
<item index="118" class="java.lang.String" itemvalue="widgetsnbextension" />
|
||||
<item index="119" class="java.lang.String" itemvalue="charset-normalizer" />
|
||||
<item index="120" class="java.lang.String" itemvalue="uc-micro-py" />
|
||||
<item index="121" class="java.lang.String" itemvalue="biopython" />
|
||||
<item index="122" class="java.lang.String" itemvalue="dask" />
|
||||
<item index="123" class="java.lang.String" itemvalue="ffmpy" />
|
||||
<item index="124" class="java.lang.String" itemvalue="langsmith" />
|
||||
<item index="125" class="java.lang.String" itemvalue="numexpr" />
|
||||
<item index="126" class="java.lang.String" itemvalue="gradio" />
|
||||
<item index="127" class="java.lang.String" itemvalue="webcolors" />
|
||||
<item index="128" class="java.lang.String" itemvalue="async-timeout" />
|
||||
<item index="129" class="java.lang.String" itemvalue="SQLAlchemy" />
|
||||
<item index="130" class="java.lang.String" itemvalue="sklearn" />
|
||||
<item index="131" class="java.lang.String" itemvalue="cloudpickle" />
|
||||
<item index="132" class="java.lang.String" itemvalue="wcwidth" />
|
||||
<item index="133" class="java.lang.String" itemvalue="jupyter_core" />
|
||||
<item index="134" class="java.lang.String" itemvalue="importlib-metadata" />
|
||||
<item index="135" class="java.lang.String" itemvalue="rfc3986-validator" />
|
||||
<item index="136" class="java.lang.String" itemvalue="typeguard" />
|
||||
<item index="137" class="java.lang.String" itemvalue="ncls" />
|
||||
<item index="138" class="java.lang.String" itemvalue="jsonschema-specifications" />
|
||||
<item index="139" class="java.lang.String" itemvalue="rpds-py" />
|
||||
<item index="140" class="java.lang.String" itemvalue="uri-template" />
|
||||
<item index="141" class="java.lang.String" itemvalue="fissix" />
|
||||
<item index="142" class="java.lang.String" itemvalue="urllib3" />
|
||||
<item index="143" class="java.lang.String" itemvalue="jupyterlab" />
|
||||
<item index="144" class="java.lang.String" itemvalue="Cython" />
|
||||
<item index="145" class="java.lang.String" itemvalue="six" />
|
||||
<item index="146" class="java.lang.String" itemvalue="pyTelegramBotAPI" />
|
||||
<item index="147" class="java.lang.String" itemvalue="nbformat" />
|
||||
<item index="148" class="java.lang.String" itemvalue="ipython" />
|
||||
<item index="149" class="java.lang.String" itemvalue="dill" />
|
||||
<item index="150" class="java.lang.String" itemvalue="volatile" />
|
||||
<item index="151" class="java.lang.String" itemvalue="fastjsonschema" />
|
||||
<item index="152" class="java.lang.String" itemvalue="prometheus-client" />
|
||||
<item index="153" class="java.lang.String" itemvalue="tqdm" />
|
||||
<item index="154" class="java.lang.String" itemvalue="fastapi" />
|
||||
<item index="155" class="java.lang.String" itemvalue="proto-plus" />
|
||||
<item index="156" class="java.lang.String" itemvalue="aiohttp" />
|
||||
<item index="157" class="java.lang.String" itemvalue="grpcio" />
|
||||
<item index="158" class="java.lang.String" itemvalue="async-lru" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="N803" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredIdentifiers">
|
||||
<list>
|
||||
<option value="random.random.choice" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="ASK" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/robot-mors-object-track.iml" filepath="$PROJECT_DIR$/.idea/robot-mors-object-track.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/librealsense" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,19 @@
|
||||
from ultralytics import YOLO
|
||||
import cv2
|
||||
|
||||
model = YOLO('./models/yolov9e_object_classification.pt')
|
||||
|
||||
image_path = './assets/classification_images/rgb_web_ex.jpeg'
|
||||
image = cv2.imread(image_path)
|
||||
|
||||
results = model(image)
|
||||
|
||||
annotated_image = results[0].plot()
|
||||
|
||||
output_path = './assets/classification_images/annotated_image.jpg'
|
||||
cv2.imwrite(output_path, annotated_image)
|
||||
print(f"Annotated image saved to {output_path}")
|
||||
|
||||
cv2.imshow('Detected Objects', annotated_image)
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
@ -0,0 +1,21 @@
|
||||
import numpy as np
|
||||
from Neko.RealSense import RealSenseController
|
||||
from Neko.CameraProcessor import CameraProcessor
|
||||
from Neko.TargetFollower import TargetFollower
|
||||
from Neko.Visualization3D import Visualization3D
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
camera_processor = CameraProcessor()
|
||||
detections_info, annotated_image = camera_processor.inline_detection()
|
||||
|
||||
if annotated_image is not None and detections_info:
|
||||
image_height, image_width, _ = annotated_image.shape
|
||||
camera_position = np.array([image_width / 2, image_height, 0])
|
||||
|
||||
follower = TargetFollower(detections_info, annotated_image, camera_position=camera_position)
|
||||
selected_target = follower.select_target('person', nearest=True) # Задайте имя класса для следования
|
||||
follow_vector = follower.calculate_follow_vector()
|
||||
|
||||
visualizer = Visualization3D(camera_position=camera_position)
|
||||
visualizer.plot_scene(detections_info, follow_vector=follow_vector)
|
@ -0,0 +1,88 @@
|
||||
import pyrealsense2 as rs
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.animation import FuncAnimation
|
||||
import cv2
|
||||
|
||||
# RS_WIDTH = 1280
|
||||
# RS_HEIGHT = 720
|
||||
|
||||
RS_WIDTH = 640
|
||||
RS_HEIGHT = 480
|
||||
|
||||
|
||||
class RealSenseInterface:
|
||||
|
||||
def noCameraFound(self):
|
||||
print("RealSense camera not found. Check the connection.")
|
||||
|
||||
|
||||
class ImageAcquisition(RealSenseInterface):
|
||||
|
||||
def __init__(self):
|
||||
try:
|
||||
self.__pipeline = rs.pipeline()
|
||||
config = rs.config()
|
||||
config.enable_stream(rs.stream.depth, RS_WIDTH, RS_HEIGHT, rs.format.z16, 30)
|
||||
config.enable_stream(rs.stream.color, RS_WIDTH, RS_HEIGHT, rs.format.bgr8, 30)
|
||||
self.__pipeline.start(config)
|
||||
except:
|
||||
self.noCameraFound()
|
||||
exit()
|
||||
|
||||
def get_depth_image(self):
|
||||
frames = self.__pipeline.wait_for_frames()
|
||||
depth_frame = frames.get_depth_frame()
|
||||
return np.asanyarray(depth_frame.get_data()) if depth_frame else None
|
||||
|
||||
def get_color_image(self):
|
||||
frames = self.__pipeline.wait_for_frames()
|
||||
color_frame = frames.get_color_frame()
|
||||
return np.asanyarray(color_frame.get_data()) if color_frame else None
|
||||
|
||||
def stop(self):
|
||||
self.__pipeline.stop()
|
||||
|
||||
|
||||
class ImageDisplay(RealSenseInterface):
|
||||
|
||||
def display_images(self, depth_image, color_image):
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2)
|
||||
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)
|
||||
ax1.imshow(depth_colormap, cmap='jet')
|
||||
ax2.imshow(color_image)
|
||||
plt.show()
|
||||
|
||||
|
||||
class ImageSaver(RealSenseInterface):
|
||||
|
||||
def save_image(self, image, filename):
|
||||
cv2.imwrite(filename, image)
|
||||
|
||||
|
||||
class RealSenseController:
|
||||
|
||||
def __init__(self):
|
||||
self.acquisition = ImageAcquisition()
|
||||
self.display = ImageDisplay()
|
||||
self.saver = ImageSaver()
|
||||
|
||||
def start(self):
|
||||
print("RealSense 3D camera detected.")
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2)
|
||||
depth_im = ax1.imshow(np.zeros((RS_HEIGHT, RS_WIDTH, 3)), cmap='jet')
|
||||
color_im = ax2.imshow(np.zeros((RS_HEIGHT, RS_WIDTH, 3)), cmap='jet')
|
||||
|
||||
def update(frame):
|
||||
depth_image = self.acquisition.get_depth_image()
|
||||
color_image = self.acquisition.get_color_image()
|
||||
if depth_image is not None and color_image is not None:
|
||||
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)
|
||||
depth_im.set_array(depth_colormap)
|
||||
color_im.set_array(color_image)
|
||||
self.saver.save_image(color_image, "color_image.png")
|
||||
|
||||
ani = FuncAnimation(fig, update, blit=False, cache_frame_data=False)
|
||||
fig.canvas.manager.window.wm_geometry("+0+0")
|
||||
plt.show()
|
||||
self.acquisition.stop()
|
@ -0,0 +1,78 @@
|
||||
import numpy as np
|
||||
import cv2
|
||||
import matplotlib.pyplot as plt
|
||||
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
|
||||
from Neko.RealSense import RealSenseController
|
||||
from Neko.CameraProcessor import CameraProcessor
|
||||
from Neko.TargetFollower import TargetFollower
|
||||
from ultralytics import YOLO
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class Visualization3D:
|
||||
def __init__(self, camera_position):
|
||||
self.camera_position = camera_position
|
||||
|
||||
def plot_scene(self, detections_info, follow_vector=None):
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
|
||||
for detection in detections_info:
|
||||
x1, y1, x2, y2 = detection['bbox']
|
||||
mean_depth = detection['mean_depth']
|
||||
class_name = detection['class_name']
|
||||
|
||||
width = x2 - x1
|
||||
height = y2 - y1
|
||||
depth = 0.05
|
||||
|
||||
box_points = [
|
||||
[x1, y1, mean_depth],
|
||||
[x2, y1, mean_depth],
|
||||
[x2, y2, mean_depth],
|
||||
[x1, y2, mean_depth],
|
||||
[x1, y1, mean_depth + depth],
|
||||
[x2, y1, mean_depth + depth],
|
||||
[x2, y2, mean_depth + depth],
|
||||
[x1, y2, mean_depth + depth]
|
||||
]
|
||||
|
||||
faces = [
|
||||
[box_points[0], box_points[1], box_points[5], box_points[4]],
|
||||
[box_points[3], box_points[2], box_points[6], box_points[7]],
|
||||
[box_points[0], box_points[3], box_points[7], box_points[4]],
|
||||
[box_points[1], box_points[2], box_points[6], box_points[5]],
|
||||
[box_points[0], box_points[1], box_points[2], box_points[3]],
|
||||
[box_points[4], box_points[5], box_points[6], box_points[7]]
|
||||
]
|
||||
|
||||
box = Poly3DCollection(faces, facecolors='cyan', linewidths=1, edgecolors='r', alpha=0.25)
|
||||
ax.add_collection3d(box)
|
||||
|
||||
ax.text((x1 + x2) / 2, (y1 + y2) / 2, mean_depth + depth, f'{class_name} {mean_depth:.2f}m',
|
||||
color='blue', fontsize=8)
|
||||
|
||||
if follow_vector is not None:
|
||||
target_position = self.camera_position + follow_vector
|
||||
ax.quiver(
|
||||
self.camera_position[0], self.camera_position[1], self.camera_position[2],
|
||||
follow_vector[0], follow_vector[1], follow_vector[2],
|
||||
color='red', arrow_length_ratio=0.1
|
||||
)
|
||||
ax.text(target_position[0], target_position[1], target_position[2],
|
||||
"Target", color='red', fontsize=10)
|
||||
|
||||
ax.set_xlabel("X")
|
||||
ax.set_ylabel("Y")
|
||||
ax.set_zlabel("Depth (m)")
|
||||
ax.set_title("3D Scene with Follow Vector")
|
||||
|
||||
all_x = [d['bbox'][0] for d in detections_info] + [d['bbox'][2] for d in detections_info]
|
||||
all_y = [d['bbox'][1] for d in detections_info] + [d['bbox'][3] for d in detections_info]
|
||||
all_z = [d['mean_depth'] for d in detections_info] + [d['mean_depth'] + 0.05 for d in detections_info]
|
||||
|
||||
ax.set_xlim(min(all_x) - 50, max(all_x) + 50)
|
||||
ax.set_ylim(min(all_y) - 50, max(all_y) + 50)
|
||||
ax.set_zlim(min(all_z) - 0.1, max(all_z) + 0.1)
|
||||
|
||||
plt.show()
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 158 KiB |
After Width: | Height: | Size: 322 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 53 KiB |
@ -0,0 +1,29 @@
|
||||
|
||||
## Base deps:
|
||||
|
||||
```bash
|
||||
pip install opencv-python yolov5
|
||||
```
|
||||
|
||||
## Install realsense sdk:
|
||||
|
||||
|
||||
|
||||
### Mac OS
|
||||
|
||||
```bash
|
||||
brew install cmake pkg-config libusb
|
||||
```
|
||||
|
||||
Clone the official repo:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/IntelRealSense/librealsense.git
|
||||
cd librealsense
|
||||
```
|
||||
|
||||
|
||||
### Ubuntu 22.0
|
||||
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
pip install -r ./requirements.txt
|
@ -0,0 +1,24 @@
|
||||
* Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):
|
||||
|
||||
* Consider checking out SDK [examples](https://github.com/IntelRealSense/librealsense/tree/master/examples#sample-code-for-intel-realsense-cameras).
|
||||
* Have you looked in our [documentations](https://github.com/IntelRealSense/librealsense/tree/master/doc#useful-links)?
|
||||
* Is you question a [frequently asked one](https://github.com/IntelRealSense/librealsense/wiki/Troubleshooting-Q%26A)?
|
||||
* Try [searching our GitHub Issues](https://github.com/IntelRealSense/librealsense/issues?utf8=%E2%9C%93&q=is%3Aissue) (open and closed) for a similar issue.
|
||||
|
||||
* All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
| Required Info | |
|
||||
|---------------------------------|------------------------------------------- |
|
||||
| Camera Model | { R200 / F200 / SR300 / ZR300 / D400 } |
|
||||
| Firmware Version | (Open RealSense Viewer --> Click info) |
|
||||
| Operating System & Version | {Win (8.1/10) / Linux (Ubuntu 14/16/17) / MacOS |
|
||||
| Kernel Version (Linux Only) | (e.g. 4.14.13) |
|
||||
| Platform | PC/Raspberry Pi/ NVIDIA Jetson / etc.. |
|
||||
| SDK Version | { legacy / 2.<?>.<?> } |
|
||||
| Language | {C/C#/labview/nodejs/opencv/pcl/python/unity } |
|
||||
| Segment | {Robot/Smartphone/VR/AR/others } |
|
||||
|
||||
### Issue Description
|
||||
<Describe your issue / question / feature request / etc..>
|
@ -0,0 +1,9 @@
|
||||
<!--
|
||||
Pull requests should go to the development branch:
|
||||
https://github.com/IntelRealSense/librealsense/tree/development/
|
||||
|
||||
If this is still a work-in-progress, please open it as DRAFT.
|
||||
|
||||
For further details, please see our contribution guidelines:
|
||||
https://github.com/IntelRealSense/librealsense/blob/master/CONTRIBUTING.md
|
||||
-->
|
@ -0,0 +1,58 @@
|
||||
name: build_lrs_ROS2_package
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['**']
|
||||
pull_request:
|
||||
branches: ['**']
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
|
||||
build_lrs_ros2_package:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
matrix:
|
||||
ros_distribution:
|
||||
- humble
|
||||
- iron
|
||||
- rolling
|
||||
|
||||
include:
|
||||
# Humble Hawksbill
|
||||
- docker_image: ubuntu:jammy
|
||||
ros_distribution: humble
|
||||
|
||||
# Iron Irwini
|
||||
- docker_image: ubuntu:jammy
|
||||
ros_distribution: iron
|
||||
|
||||
# Rolling Ridley
|
||||
- docker_image: ubuntu:jammy
|
||||
ros_distribution: rolling
|
||||
|
||||
container:
|
||||
image: ${{ matrix.docker_image }}
|
||||
steps:
|
||||
|
||||
- name: setup ROS environment
|
||||
uses: ros-tooling/setup-ros@44e00e21351330f8dbc9f298bc179cd0c7910477 # v0.7
|
||||
with:
|
||||
required-ros-distributions: ${{ matrix.ros_distribution }}
|
||||
|
||||
- name: build librealsense ROS 2
|
||||
uses: ros-tooling/action-ros-ci@0c87ffc035492b66c9afb9159ca9664fb0b513e1 # v0.3
|
||||
with:
|
||||
target-ros2-distro: ${{ matrix.ros_distribution }}
|
||||
skip-tests: true
|
||||
colcon-defaults: | # We align the build flags to the librealsense2 ROS2 release build.
|
||||
{
|
||||
"build": {
|
||||
"cmake-args": [
|
||||
"-DBUILD_GRAPHICAL_EXAMPLES=OFF",
|
||||
"-DBUILD_EXAMPLES=OFF"
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,548 @@
|
||||
name: Build_CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['**']
|
||||
pull_request:
|
||||
branches: ['**']
|
||||
|
||||
permissions: read-all
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
LRS_BUILD_CONFIG: Debug
|
||||
LRS_RUN_CONFIG: Release
|
||||
LRS_RUN_WITH_DEB_CONFIG: RelWithDebInfo
|
||||
PYTHON_PATH: C:\\hostedtoolcache\\windows\\Python\\3.8.1\\x64\\python.exe
|
||||
# GH-Actions Windows VM currently supply ~14 GB available on D drive, and ~80 GB on drive C.
|
||||
# Building LRS statically with third parties is too much for drive D so we clone to drive 'D' and build on drive 'C'
|
||||
WIN_BUILD_DIR: C:/lrs_build
|
||||
|
||||
|
||||
jobs:
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
Win_SH_EX_CfU: # Windows, shared, with Examples & Tools, and Check for Updates
|
||||
runs-on: windows-2019
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- name: Enable Long Paths
|
||||
shell: powershell
|
||||
run: |
|
||||
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
|
||||
|
||||
- name: Check_API
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts
|
||||
./api_check.sh
|
||||
cd ..
|
||||
|
||||
- name: PreBuild
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir ${{env.WIN_BUILD_DIR}}
|
||||
|
||||
- name: Configure CMake
|
||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||
shell: bash
|
||||
run: |
|
||||
LRS_SRC_DIR=$(pwd)
|
||||
cd ${{env.WIN_BUILD_DIR}}
|
||||
pwd
|
||||
ls
|
||||
cmake ${LRS_SRC_DIR} -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=true -DBUILD_TOOLS=true -DCHECK_FOR_UPDATES=true
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
shell: bash
|
||||
run: |
|
||||
cd ${{env.WIN_BUILD_DIR}}
|
||||
cmake --build . --config ${{env.LRS_RUN_CONFIG}} -- -m
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
Win_SH_EX_No_Logs: # Windows, shared, with Examples & Tools, no EasyLogging and no Check for Updates
|
||||
runs-on: windows-2019
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- name: Enable Long Paths
|
||||
shell: powershell
|
||||
run: |
|
||||
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
|
||||
|
||||
- name: Check_API
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts
|
||||
./api_check.sh
|
||||
cd ..
|
||||
|
||||
- name: PreBuild
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir ${{env.WIN_BUILD_DIR}}
|
||||
|
||||
- name: Configure CMake
|
||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||
shell: bash
|
||||
run: |
|
||||
LRS_SRC_DIR=$(pwd)
|
||||
cd ${{env.WIN_BUILD_DIR}}
|
||||
pwd
|
||||
ls
|
||||
cmake ${LRS_SRC_DIR} -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=true -DBUILD_TOOLS=true -DCHECK_FOR_UPDATES=false -DBUILD_EASYLOGGINGPP=false
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
shell: bash
|
||||
run: |
|
||||
cd ${{env.WIN_BUILD_DIR}}
|
||||
cmake --build . --config ${{env.LRS_RUN_CONFIG}} -- -m
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
Win_ST_Py_CI: # Windows, Static, Python, Tools, libCI with executables
|
||||
runs-on: windows-2019
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
- uses: actions/setup-python@3542bca2639a428e1796aaa6a2ffef0c0f575566 # v3.1.4
|
||||
with:
|
||||
python-version: '3.8.1'
|
||||
|
||||
- name: Enable Long Paths
|
||||
shell: powershell
|
||||
run: |
|
||||
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
|
||||
|
||||
- name: Check_API
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts
|
||||
./api_check.sh
|
||||
cd ..
|
||||
|
||||
- name: PreBuild
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir ${{env.WIN_BUILD_DIR}}
|
||||
python3 -m pip install numpy
|
||||
|
||||
- name: Configure CMake
|
||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||
shell: bash
|
||||
run: |
|
||||
LRS_SRC_DIR=$(pwd)
|
||||
cd ${{env.WIN_BUILD_DIR}}
|
||||
cmake ${LRS_SRC_DIR} -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=false -DBUILD_EXAMPLES=false -DBUILD_TOOLS=true -DBUILD_UNIT_TESTS=true -DUNIT_TESTS_ARGS="--not-live --context=windows" -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=false -DPYTHON_EXECUTABLE=${{env.PYTHON_PATH}} -DBUILD_PYTHON_BINDINGS=true
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
shell: bash
|
||||
run: |
|
||||
cd ${{env.WIN_BUILD_DIR}}
|
||||
cmake --build . --config ${{env.LRS_RUN_CONFIG}} -- -m
|
||||
|
||||
- name: LibCI
|
||||
# Note: requires BUILD_UNIT_TESTS or the executable C++ unit-tests won't run (and it won't complain)
|
||||
shell: bash
|
||||
run: |
|
||||
python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "windows" ${{env.WIN_BUILD_DIR}}/Release
|
||||
|
||||
- name: Client for realsense2-all
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir ${{env.WIN_BUILD_DIR}}/rs-all-client
|
||||
cd ${{env.WIN_BUILD_DIR}}/rs-all-client
|
||||
cmake $GITHUB_WORKSPACE/.github/workflows/rs-all-client -G "Visual Studio 16 2019"
|
||||
cmake --build . --config Release -- -m
|
||||
./Release/rs-all-client
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
Win_SH_Py_DDS_CI: # Windows, Shared, Python, Tools, DDS, libCI without executables
|
||||
runs-on: windows-2019
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
- uses: actions/setup-python@3542bca2639a428e1796aaa6a2ffef0c0f575566 # v3.1.4
|
||||
with:
|
||||
python-version: '3.8.1'
|
||||
|
||||
- name: Enable Long Paths
|
||||
shell: powershell
|
||||
run: |
|
||||
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
|
||||
|
||||
- name: Check_API
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts
|
||||
./api_check.sh
|
||||
cd ..
|
||||
|
||||
- name: PreBuild
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir ${{env.WIN_BUILD_DIR}}
|
||||
python3 -m pip install numpy
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
run: |
|
||||
LRS_SRC_DIR=$(pwd)
|
||||
cd ${{env.WIN_BUILD_DIR}}
|
||||
cmake ${LRS_SRC_DIR} -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=false -DBUILD_TOOLS=true -DBUILD_UNIT_TESTS=false -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=true -DPYTHON_EXECUTABLE=${{env.PYTHON_PATH}} -DBUILD_PYTHON_BINDINGS=true
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
shell: bash
|
||||
run: |
|
||||
cd ${{env.WIN_BUILD_DIR}}
|
||||
cmake --build . --config ${{env.LRS_RUN_CONFIG}} -- -m
|
||||
|
||||
- name: LibCI
|
||||
# Note: we specifically disable BUILD_UNIT_TESTS so the executable C++ unit-tests won't run
|
||||
# This is to save time as DDS already lengthens the build...
|
||||
shell: bash
|
||||
run: |
|
||||
python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "dds windows" ${{env.WIN_BUILD_DIR}}/Release
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
Win_SH_Py_RSUSB_Csharp: # Windows, Shared, Python, RSUSB backend, C# bindings
|
||||
runs-on: windows-2019
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
- uses: actions/setup-python@3542bca2639a428e1796aaa6a2ffef0c0f575566 # v3.1.4
|
||||
with:
|
||||
python-version: '3.8.1'
|
||||
|
||||
- name: Enable Long Paths
|
||||
shell: powershell
|
||||
run: |
|
||||
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
|
||||
|
||||
- name: Check_API
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts
|
||||
./api_check.sh
|
||||
cd ..
|
||||
|
||||
- name: PreBuild
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir ${{env.WIN_BUILD_DIR}}
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
run: |
|
||||
LRS_SRC_DIR=$(pwd)
|
||||
cd ${{env.WIN_BUILD_DIR}}
|
||||
cmake ${LRS_SRC_DIR} -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=false -DBUILD_TOOLS=false -DCHECK_FOR_UPDATES=false -DPYTHON_EXECUTABLE=${{env.PYTHON_PATH}} -DBUILD_PYTHON_BINDINGS=true -DFORCE_RSUSB_BACKEND=true -DBUILD_CSHARP_BINDINGS=true -DDOTNET_VERSION_LIBRARY="4.5" -DDOTNET_VERSION_EXAMPLES="4.5"
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
shell: bash
|
||||
run: |
|
||||
cd ${{env.WIN_BUILD_DIR}}
|
||||
cmake --build . --config ${{env.LRS_BUILD_CONFIG}} -- -m
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
U22_ST_Py_EX_CfU_LiveTest: # Ubuntu 2022, Static, Python, Examples & Tools, Check for Updates, Legacy Live-Tests
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- name: Prebuild
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts && ./api_check.sh && cd ..
|
||||
mkdir build && cd build
|
||||
export LRS_LOG_LEVEL="DEBUG";
|
||||
sudo apt-get update;
|
||||
sudo apt-get install -qq build-essential xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev libglm-dev;
|
||||
sudo apt-get install -qq libusb-1.0-0-dev;
|
||||
sudo apt-get install -qq libgtk-3-dev;
|
||||
sudo apt-get install libglfw3-dev libglfw3;
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_RUN_CONFIG}} -DBUILD_SHARED_LIBS=false -DBUILD_EXAMPLES=true -DBUILD_TOOLS=true -DCHECK_FOR_UPDATES=true -DBUILD_LEGACY_LIVE_TEST=true -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3)
|
||||
cmake --build . -- -j4
|
||||
|
||||
- name: Test
|
||||
shell: bash
|
||||
id: test-step
|
||||
# We set continue-on-error: true as a workaround for not skipping the upload log step on failure,
|
||||
# The final step will check the return value from the test step and decide if to fail/pass the job
|
||||
continue-on-error: true
|
||||
run: |
|
||||
export LRS_LOG_LEVEL="DEBUG";
|
||||
cd build/${{env.LRS_RUN_CONFIG}}/
|
||||
./live-test -d yes -i [software-device]
|
||||
|
||||
- name: Upload RS log artifact
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
||||
with:
|
||||
name: Log file - U22_ST_Py_EX_CfU_LiveTest
|
||||
path: build/*.log
|
||||
|
||||
- name: Provide correct exit status for job
|
||||
shell: bash
|
||||
run: |
|
||||
if [ ${{steps.test-step.outcome}} = "failure" ];then
|
||||
echo "Test step failed, please open it to view the reported issue"
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
U20_SH_Py_CI: # Ubuntu 2020, Shared, Python, LibCI with executables
|
||||
runs-on: ubuntu-20.04
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- name: Prebuild
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update;
|
||||
sudo apt-get install -qq build-essential xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev libglm-dev;
|
||||
sudo apt-get install -qq libusb-1.0-0-dev;
|
||||
sudo apt-get install -qq libgtk-3-dev;
|
||||
sudo apt-get install libglfw3-dev libglfw3;
|
||||
# We force compiling with GCC 7 because the default installed GCC 9 compiled with LTO and gives an internal compiler error
|
||||
sudo apt-get install gcc-7 g++-7;
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7;
|
||||
python3 -m pip install numpy
|
||||
|
||||
- name: Check_API
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts
|
||||
./api_check.sh
|
||||
./pr_check.sh
|
||||
cd ..
|
||||
mkdir build
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_RUN_CONFIG}} -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=false -DBUILD_TOOLS=true -DBUILD_UNIT_TESTS=true -DUNIT_TESTS_ARGS="--not-live --context=linux" -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=false -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3)
|
||||
cmake --build . -- -j4
|
||||
|
||||
- name: LibCI
|
||||
# Note: requires BUILD_UNIT_TESTS or the executable C++ unit-tests won't run (and it won't complain)
|
||||
shell: bash
|
||||
run: |
|
||||
python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "linux"
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
U20_ST_Py_DDS_RSUSB_CI: # Ubuntu 2020, Static, Python, DDS, RSUSB, LibCI without executables
|
||||
runs-on: ubuntu-20.04
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- name: Prebuild
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update;
|
||||
sudo apt-get install -qq build-essential xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev libglm-dev;
|
||||
sudo apt-get install -qq libusb-1.0-0-dev;
|
||||
sudo apt-get install -qq libgtk-3-dev;
|
||||
sudo apt-get install libglfw3-dev libglfw3;
|
||||
# We force compiling with GCC 7 because the default installed GCC 9 compiled with LTO and gives an internal compiler error
|
||||
sudo apt-get install gcc-7 g++-7;
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7;
|
||||
python3 -m pip install numpy
|
||||
|
||||
- name: Check_API
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts
|
||||
./api_check.sh
|
||||
./pr_check.sh
|
||||
cd ..
|
||||
mkdir build
|
||||
|
||||
- name: Build
|
||||
# Note: we force RSUSB because, on Linux, the context creation will fail on GHA:
|
||||
# (backend-v4l2.cpp:555) Cannot access /sys/class/video4linux)
|
||||
# And, well, we don't need any specific platform for DDS!
|
||||
shell: bash
|
||||
run: |
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_RUN_CONFIG}} -DBUILD_SHARED_LIBS=false -DBUILD_EXAMPLES=false -DBUILD_TOOLS=false -DBUILD_UNIT_TESTS=false -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=true -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3) -DFORCE_RSUSB_BACKEND=true
|
||||
cmake --build . -- -j4
|
||||
|
||||
- name: Client for realsense2-all
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir build/rs-all-client
|
||||
cd build/rs-all-client
|
||||
cmake ../../.github/workflows/rs-all-client -DBUILD_WITH_DDS=ON -DFORCE_RSUSB_BACKEND=ON
|
||||
cmake --build . -- -j4
|
||||
./rs-all-client
|
||||
|
||||
- name: LibCI
|
||||
# Note: we specifically disable BUILD_UNIT_TESTS so the executable C++ unit-tests won't run
|
||||
# This is to save time as DDS already lengthens the build...
|
||||
shell: bash
|
||||
run: |
|
||||
python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "dds linux" --tag dds
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
U22_SH_RSUSB_LiveTest: # Ubuntu 2022, Shared, Legacy live-tests
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 60
|
||||
env:
|
||||
LRS_BUILD_NODEJS: true
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- name: Check_API
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts
|
||||
./api_check.sh
|
||||
cd ..
|
||||
|
||||
- name: Prebuild
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
|
||||
mkdir build
|
||||
sudo apt-get update;
|
||||
sudo apt-get install -qq build-essential xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev libglm-dev;
|
||||
sudo apt-get install -qq libusb-1.0-0-dev;
|
||||
sudo apt-get install -qq libgtk-3-dev;
|
||||
sudo apt-get install libglfw3-dev libglfw3;
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_BUILD_CONFIG}} -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=false -DBUILD_TOOLS=false -DCHECK_FOR_UPDATES=false -DFORCE_RSUSB_BACKEND=true -DBUILD_LEGACY_LIVE_TEST=true
|
||||
cmake --build . -- -j4
|
||||
|
||||
- name: Test
|
||||
shell: bash
|
||||
id: test-step
|
||||
# We set continue-on-error: true as a workaround for not skipping the upload log step on failure,
|
||||
# The final step will check the return value from the test step and decide if to fail/pass the job
|
||||
continue-on-error: true
|
||||
run: |
|
||||
export LRS_LOG_LEVEL="DEBUG";
|
||||
cd build/${{env.LRS_BUILD_CONFIG}}/
|
||||
./live-test -d yes -i [software-device]
|
||||
|
||||
- name: Upload RS log artifact
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
||||
with:
|
||||
name: Log file - U22_SH_RSUSB_LiveTest
|
||||
path: build/*.log
|
||||
|
||||
- name: Provide correct exit status for job
|
||||
shell: bash
|
||||
run: |
|
||||
if [ ${{steps.test-step.outcome}} = "failure" ];then
|
||||
echo "Test step failed, please open it to view the reported issue"
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
Mac_cpp:
|
||||
runs-on: macos-11
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- name: Check_API
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts
|
||||
./api_check.sh
|
||||
cd ..
|
||||
|
||||
- name: Prebuild
|
||||
run: |
|
||||
mkdir build
|
||||
# install coreutils for greadlink use
|
||||
brew install coreutils
|
||||
brew install homebrew/core/glfw3;
|
||||
brew list libusb || brew install libusb;
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd build
|
||||
# `OPENSSL_ROOT_DIR` setting is Used by libcurl for 'CHECK_FOR_UPDATES' capability
|
||||
# We use "greadlink -f" which is mac-os parallel command to "readlink -f" from Linux (-f to convert relative link to absolute link)
|
||||
export OPENSSL_ROOT_DIR=`greadlink -f /usr/local/opt/openssl@1.1`
|
||||
echo "OPENSSL_ROOT_DIR = ${OPENSSL_ROOT_DIR}"
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_BUILD_CONFIG}} -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DCHECK_FOR_UPDATES=true
|
||||
cmake --build . -- -j4
|
||||
ls
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
Android_cpp:
|
||||
runs-on: ubuntu-20.04
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- name: Check_API
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts
|
||||
./api_check.sh
|
||||
cd ..
|
||||
- name: Prebuild
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir build
|
||||
wget https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip;
|
||||
unzip -q android-ndk-r20b-linux-x86_64.zip -d ./;
|
||||
sudo apt-get update;
|
||||
sudo apt-get install -qq build-essential xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev libglm-dev;
|
||||
sudo apt-get install -qq libusb-1.0-0-dev;
|
||||
sudo apt-get install -qq libgtk-3-dev;
|
||||
sudo apt-get install libglfw3-dev libglfw3;
|
||||
# We force compiling with GCC 7 because the default installed GCC 9 compiled with LTO and gives an internal compiler error
|
||||
sudo apt-get install gcc-7 g++-7;
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7;
|
||||
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_BUILD_CONFIG}} -DCMAKE_TOOLCHAIN_FILE=../android-ndk-r20b/build/cmake/android.toolchain.cmake -DFORCE_RSUSB_BACKEND=true
|
||||
cmake --build . -- -j4
|
||||
ls
|
||||
|
@ -0,0 +1,89 @@
|
||||
# Parser for cppcheck_run.log files
|
||||
|
||||
import sys
|
||||
def usage():
|
||||
print( 'usage: python chhpcheck-parse.py [OPTIONS] <path-to-log>' )
|
||||
print( ' --severity <W|E|l> limit which severities are shown (Warnings, Errors, locations; default=WEl)' )
|
||||
sys.exit(1)
|
||||
|
||||
import getopt
|
||||
try:
|
||||
opts, args = getopt.getopt( sys.argv[1:], 'h',
|
||||
longopts=['help', 'severity='] )
|
||||
except getopt.GetoptError as err:
|
||||
print( '-F-', err ) # something like "option -a not recognized"
|
||||
usage()
|
||||
if len(args) != 1:
|
||||
usage()
|
||||
logfile = args[0]
|
||||
|
||||
severities = 'WEl'
|
||||
for opt, arg in opts:
|
||||
if opt in ('--severity'):
|
||||
severities = arg
|
||||
|
||||
|
||||
class LineError( Exception ):
|
||||
def __init__( self, message, line=None ):
|
||||
global line_number, logfile
|
||||
if line is None:
|
||||
line = line_number
|
||||
super().__init__( f'{logfile}+{line}: {message}' )
|
||||
|
||||
|
||||
handle = open( logfile, "r" )
|
||||
line_number = 0
|
||||
def nextline():
|
||||
global handle, line_number
|
||||
line_number += 1
|
||||
line = handle.readline()
|
||||
if not line:
|
||||
raise LineError( 'unexpected end-of-file' )
|
||||
return line.strip()
|
||||
|
||||
while True:
|
||||
line = nextline()
|
||||
if line == '<errors>':
|
||||
break
|
||||
|
||||
import re
|
||||
while True:
|
||||
line = nextline()
|
||||
if line == '</errors>':
|
||||
break
|
||||
if not line.startswith( '<error ' ):
|
||||
raise LineError( 'unexpected line' )
|
||||
|
||||
#print( f'-D-{line_number}- {line}' )
|
||||
e = dict( re.findall( '(\w+)="(.*?)"', line ) )
|
||||
severity = e['severity'][0].capitalize()
|
||||
id = e['id']
|
||||
cwe = e.get( 'cwe', '-' )
|
||||
file0 = e.get( 'file0', '' )
|
||||
msg = e['msg'].replace( ''', "'" )
|
||||
|
||||
line = nextline()
|
||||
printed = False
|
||||
while( line.startswith( '<location ' )):
|
||||
l = dict( re.findall( '(\w+)="(.*?)"', line ) )
|
||||
file = l['file']
|
||||
line = l['line']
|
||||
column = l['column']
|
||||
info = l.get( 'info', '' )
|
||||
if severity in severities:
|
||||
if 'l' in severities:
|
||||
if not printed:
|
||||
print( f'{severity} {id:30} {file0:50} {msg}' )
|
||||
print( f'| {"-":30} {file+"+"+line+"."+column:50} {info}' )
|
||||
elif not printed:
|
||||
print( f'{severity} {id:30} {file+"+"+line:50} {msg}' )
|
||||
printed = True
|
||||
line = nextline()
|
||||
if not printed: # no locations!?
|
||||
if severity in severities:
|
||||
print( f'{severity} {id:30} {file0 or file:50} {msg}' )
|
||||
|
||||
if line != '</error>':
|
||||
raise LineError( 'unknown error line' )
|
||||
|
||||
sys.exit(0)
|
@ -0,0 +1,53 @@
|
||||
# License: Apache 2.0. See LICENSE file in root directory.
|
||||
# Copyright(c) 2023 Intel Corporation. All Rights Reserved.
|
||||
cmake_minimum_required( VERSION 3.15 )
|
||||
|
||||
#
|
||||
# This tests whether we can link with realsense2-all and not have any missing external symbols.
|
||||
# Without realsense2-all, we'd need to link with:
|
||||
# realsense2 realsense-file rsutils
|
||||
# Or, if DDS was enabled:
|
||||
# realsense2 realsense-file rsutils fastcdr fastrtps foonathan_memory realdds
|
||||
# And the list gets longer if we add libraries.
|
||||
#
|
||||
# On Windows, no additional special libraries are needed.
|
||||
# On Linux, we have other dependencies:
|
||||
# libusb udev
|
||||
# These are not part of realsense2-all, even though we depend on them!
|
||||
#
|
||||
|
||||
project( rs-all-client )
|
||||
|
||||
option( BUILD_SHARED_LIBS "Build using shared libraries" OFF )
|
||||
|
||||
if( WIN32 )
|
||||
# Take away the other configurations because they'd require we picked another link
|
||||
# directory and target... keep it simple...
|
||||
set( CMAKE_CONFIGURATION_TYPES "Release" )
|
||||
endif()
|
||||
|
||||
add_executable( ${PROJECT_NAME} main.cpp )
|
||||
set_target_properties( ${PROJECT_NAME} PROPERTIES
|
||||
CXX_STANDARD 14
|
||||
MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug> # New in version 3.15; ignored in Linux
|
||||
)
|
||||
|
||||
target_include_directories( ${PROJECT_NAME} PRIVATE
|
||||
../../../include
|
||||
../../../third-party/rsutils/include
|
||||
)
|
||||
target_link_directories( ${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/../Release )
|
||||
|
||||
target_link_libraries( ${PROJECT_NAME} PRIVATE realsense2-all )
|
||||
|
||||
if( NOT WIN32 )
|
||||
find_library( LIBUSB NAMES usb-1.0 )
|
||||
target_link_libraries( ${PROJECT_NAME} PRIVATE pthread ${LIBUSB} )
|
||||
if( NOT FORCE_RSUSB_BACKEND )
|
||||
target_link_libraries( ${PROJECT_NAME} PRIVATE udev )
|
||||
endif()
|
||||
if( BUILD_WITH_DDS )
|
||||
target_link_libraries( ${PROJECT_NAME} PRIVATE ssl crypto rt )
|
||||
endif()
|
||||
endif()
|
||||
|
@ -0,0 +1,56 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2023 Intel Corporation. All Rights Reserved.
|
||||
|
||||
#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API
|
||||
|
||||
#include <rsutils/time/timer.h>
|
||||
#include <iostream> // for cout
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
int main(int argc, char * argv[]) try
|
||||
{
|
||||
rs2::log_to_console( RS2_LOG_SEVERITY_DEBUG );
|
||||
|
||||
rs2::context context;
|
||||
auto devices = context.query_devices();
|
||||
if( devices.size() )
|
||||
{
|
||||
// This can run under GHA, too -- so we don't always have devices
|
||||
// Run for just a little bit, count the frames
|
||||
size_t n_frames = 0;
|
||||
{
|
||||
rs2::pipeline p( context );
|
||||
auto profile = p.start();
|
||||
auto device = profile.get_device();
|
||||
std::cout << "Streaming on " << device.get_info( RS2_CAMERA_INFO_NAME ) << std::endl;
|
||||
|
||||
rsutils::time::timer timer( std::chrono::seconds( 3 ) );
|
||||
while( ! timer.has_expired() )
|
||||
{
|
||||
// Block program until frames arrive
|
||||
rs2::frameset frames = p.wait_for_frames();
|
||||
++n_frames;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Got " << n_frames << " frames" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Allow enough time for DDS enumeration
|
||||
std::this_thread::sleep_for( std::chrono::seconds( 3 ) );
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
catch (const rs2::error & e)
|
||||
{
|
||||
std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
@ -0,0 +1,196 @@
|
||||
name: static_analysis
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['**']
|
||||
pull_request:
|
||||
branches: ['**']
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
CppCheck:
|
||||
name: CppCheck
|
||||
timeout-minutes: 30
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- name: Install
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update;
|
||||
sudo apt-get install -qq cppcheck;
|
||||
|
||||
- name: Run
|
||||
shell: bash
|
||||
#Selected run options:
|
||||
# ./xxx : Folders to scan
|
||||
# --quiet : Don't show current checked configuration in log
|
||||
# --std=c++11 : Use C++11 standard (default but worth mentioning)
|
||||
# --xml : Output in XML format
|
||||
# -j4 : Run parallel jobs for a faster scan. current HW is 2 core (https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners) using 4 to future proof
|
||||
# --enable : Additional check to run. options are [all, warning, style, performance, protability, information, unusedFunction, missingInclude]
|
||||
# -I : Include directories
|
||||
# -i : Ignore directories. Ignore third-party libs that we don't want to check
|
||||
# --suppress : Don't issue errors about files matching the expression (when -i for folders is not enough)
|
||||
# --force : Check all configurations, takes a very long time (~2 hours) and did not find additional errors. Removed.
|
||||
# --max-configs=6 : Using less configuration permutations (default is 12) to reduce run time. Detects less errors. Removed.
|
||||
# -Dxxx : preprocessor configuration to use. Relevant flags taken from build on Ubuntu.
|
||||
run: >
|
||||
cppcheck ./src ./include ./common ./tools ./examples ./third-party/realdds ./third-party/rsutils
|
||||
--quiet --std=c++11 --xml -j4 --enable=warning
|
||||
-I./src -I./include -I./third-party/rsutils/include -I./common
|
||||
-i./src/mf -i./src/uvc -i./src/win -i./src/winusb --suppress=*:third-party/json.hpp
|
||||
-DBUILD_WITH_DDS -DHWM_OVER_XU -DRS2_USE_V4L2_BACKEND -DUNICODE -DUSING_UDEV -DCHECK_FOR_UPDATES -D__linux__
|
||||
&> cppcheck_run.log
|
||||
|
||||
- name: Diff
|
||||
id: diff-step
|
||||
continue-on-error: true
|
||||
shell: bash
|
||||
run: |
|
||||
python3 .github/workflows/cppcheck-parse.py --severity E cppcheck_run.log | sort --key 3 > cppcheck_run.parsed.log
|
||||
python3 .github/workflows/cppcheck-parse.py --severity E .github/workflows/cppcheck_run.log | sort --key 3 > cppcheck_run.parsed.golden
|
||||
diff cppcheck_run.parsed.golden cppcheck_run.parsed.log \
|
||||
&& echo "No diffs found in cppcheck_run.log"
|
||||
|
||||
- name: Ensure cppcheck_run.parsed.log was updated
|
||||
id: diff-parsed-step
|
||||
continue-on-error: true
|
||||
shell: bash
|
||||
run: |
|
||||
diff cppcheck_run.parsed.golden .github/workflows/cppcheck_run.parsed.log \
|
||||
&& echo "No diffs found in cppcheck_run.parsed.log"
|
||||
|
||||
- name: Upload logs
|
||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
||||
with:
|
||||
name: cppcheck_log
|
||||
path: |
|
||||
cppcheck_run.log
|
||||
cppcheck_run.parsed.log
|
||||
|
||||
- name: Provide correct exit status
|
||||
shell: bash
|
||||
run: |
|
||||
ERROR_COUNT=$(grep cppcheck_run.log -e "severity=\"error\"" -c) || ERROR_COUNT=0
|
||||
EXPECTED_ERROR_COUNT=$(grep .github/workflows/cppcheck_run.log -e "severity=\"error\"" -c) || EXPECTED_ERROR_COUNT=0
|
||||
if [ $ERROR_COUNT -eq $EXPECTED_ERROR_COUNT ]
|
||||
then
|
||||
echo "cppcheck_run succeeded, found" $ERROR_COUNT "errors, as expected"
|
||||
if [ ${{steps.diff-step.outcome}} == "failure" ]
|
||||
then
|
||||
echo "however, the ---> DIFF FAILED <---"
|
||||
elif [ ${{steps.diff-parsed-step.outcome}} == "failure" ]
|
||||
then
|
||||
echo "however, the ---> PARSED log was not UPDATED <---"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
elif [ $ERROR_COUNT -lt $EXPECTED_ERROR_COUNT ]
|
||||
then
|
||||
echo "cppcheck_run ---> SUCCEEDED <--- but found" $ERROR_COUNT "errors when expecting" $EXPECTED_ERROR_COUNT
|
||||
else
|
||||
echo "cppcheck_run ---> FAILED <--- with" $ERROR_COUNT "errors; expecting" $EXPECTED_ERROR_COUNT
|
||||
fi
|
||||
echo "see the diff step above, or the 'cppcheck_log' artifact (under Summary) for details"
|
||||
echo "commit all files in the artifact to .github/workflows/ if these are valid results"
|
||||
exit 1
|
||||
#---------------------------------------------------------------------------------------------------#
|
||||
# We verify the minimal CMake version we support is preserved when building with default CMake flags
|
||||
minimal_cmake_version:
|
||||
name: "Minimal CMake version"
|
||||
timeout-minutes: 30
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- name: "Install Dependencies"
|
||||
run: |
|
||||
work_dir=$(pwd)
|
||||
# Go back from RealSense directory to parent directory
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/nlohmann/cmake_min_version.git
|
||||
cd cmake_min_version
|
||||
# We clone a specific commit which we tested the process as working
|
||||
git checkout 687dc56e1cf52c865cebf6ac94ad67906d6e1369
|
||||
|
||||
echo "Install LibRealSense pre-installed packages requirements"
|
||||
sudo apt-get update
|
||||
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev at
|
||||
|
||||
python3 -mvenv venv
|
||||
venv/bin/pip3 install -r requirements.txt
|
||||
|
||||
- name: "Get Current CMake version"
|
||||
id: cmake_version
|
||||
run: |
|
||||
work_dir=$(pwd)
|
||||
cd ..
|
||||
|
||||
cd cmake_min_version
|
||||
venv/bin/python3 cmake_downloader.py --first_minor
|
||||
output=$(venv/bin/python3 cmake_min_version.py $work_dir)
|
||||
|
||||
# Sample of Expected Output of cmake_min_version.py ***
|
||||
# [ 0%] CMake 3.9.2 ✔ works
|
||||
# [ 12%] CMake 3.2.2 ✘ error
|
||||
# CMakeLists.txt:7 (cmake_minimum_required)
|
||||
# [ 33%] CMake 3.8.0 ✔ works
|
||||
# [ 50%] CMake 3.7.1 ✘ error
|
||||
# CMakeLists.txt:16 (target_compile_features)
|
||||
# [ 80%] CMake 3.7.2 ✘ error
|
||||
# CMakeLists.txt:16 (target_compile_features)
|
||||
# [100%] Minimal working version: CMake 3.8.0
|
||||
|
||||
# cmake_minimum_required(VERSION 3.8.0)
|
||||
|
||||
echo "$output"
|
||||
|
||||
# Retrieve CMake minimal version from the last line of the tool output.
|
||||
current_cmake_version=$(echo ${output} | grep -oP "VERSION \d+\.\d+" || echo "VERSION NOT FOUND")
|
||||
|
||||
if [ "$current_cmake_version" == "VERSION NOT FOUND" ]
|
||||
then
|
||||
echo "Error - CMake version not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
current_cmake_major_ver=$(echo $current_cmake_version | grep -oP "\d+\.\d+" | cut -d'.' -f 1)
|
||||
current_cmake_minor_ver=$(echo $current_cmake_version | grep -oP "\d+\.\d+" | cut -d'.' -f 2)
|
||||
|
||||
# Saving cmake output in GitHub output
|
||||
echo "current_cmake_major_ver=$current_cmake_major_ver" >> $GITHUB_OUTPUT
|
||||
echo "current_cmake_minor_ver=$current_cmake_minor_ver" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: "Check minimal CMake version"
|
||||
env:
|
||||
EXPECTED_CMAKE_MAJOR_VER: 3
|
||||
EXPECTED_CMAKE_MINOR_VER: 8
|
||||
CURRENT_CMAKE_MAJOR_VER: ${{ steps.cmake_version.outputs.current_cmake_major_ver }}
|
||||
CURRENT_CMAKE_MINOR_VER: ${{ steps.cmake_version.outputs.current_cmake_minor_ver }}
|
||||
|
||||
run: |
|
||||
if [ $CURRENT_CMAKE_MAJOR_VER -lt ${EXPECTED_CMAKE_MAJOR_VER} ]
|
||||
then
|
||||
STATUS="PASSED"
|
||||
elif [ $CURRENT_CMAKE_MAJOR_VER -eq ${EXPECTED_CMAKE_MAJOR_VER} ] && [ $CURRENT_CMAKE_MINOR_VER -eq ${EXPECTED_CMAKE_MINOR_VER} ]
|
||||
then
|
||||
STATUS="PASSED"
|
||||
elif [ $CURRENT_CMAKE_MAJOR_VER -eq ${EXPECTED_CMAKE_MAJOR_VER} ] && [ $CURRENT_CMAKE_MINOR_VER -lt ${EXPECTED_CMAKE_MINOR_VER} ]
|
||||
then
|
||||
STATUS="PASSED"
|
||||
else
|
||||
STATUS="FAILED"
|
||||
fi
|
||||
|
||||
if [ $STATUS == "PASSED" ]
|
||||
then
|
||||
echo "The test PASSED, current CMake version is $CURRENT_CMAKE_MAJOR_VER.$CURRENT_CMAKE_MINOR_VER and it is not higher than VERSION ${EXPECTED_CMAKE_MAJOR_VER}.${EXPECTED_CMAKE_MINOR_VER}"
|
||||
else
|
||||
echo "Error - The minimal CMake version required for LibRS is ${EXPECTED_CMAKE_MAJOR_VER}.${EXPECTED_CMAKE_MINOR_VER} but on this build the minimal CMake version that works is $CURRENT_CMAKE_MAJOR_VER.$CURRENT_CMAKE_MINOR_VER"
|
||||
exit 1
|
||||
fi
|
@ -0,0 +1,91 @@
|
||||
bin/
|
||||
lib/
|
||||
|
||||
ubuntu-xenial/
|
||||
ubuntu-xenial-hwe/
|
||||
|
||||
# Docs
|
||||
doc/doxygen/html/
|
||||
*.html.lnk
|
||||
|
||||
# CMake
|
||||
build*/
|
||||
connectivity_check
|
||||
|
||||
# XCode
|
||||
.DS_Store
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
*.xcuserstate
|
||||
librealsense.xc/build
|
||||
|
||||
*~
|
||||
*.TMP
|
||||
*.a
|
||||
*.o
|
||||
*.so
|
||||
*.pyc
|
||||
*.class
|
||||
|
||||
local_ignore/
|
||||
|
||||
#Visual Studio Project
|
||||
.vs/*
|
||||
|
||||
#Clion Project
|
||||
.idea/*
|
||||
|
||||
# QTCreator Project
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
*.user
|
||||
*.user.*
|
||||
*.moc
|
||||
moc_*.cpp
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
Makefile*
|
||||
*-build-*
|
||||
librealsense-log.txt
|
||||
|
||||
*.pyproj
|
||||
*.orig
|
||||
*.psess
|
||||
*.vspx
|
||||
*.vsp
|
||||
*.bak
|
||||
*.bin
|
||||
*.suo
|
||||
*.tlog
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.exp
|
||||
*.log
|
||||
*.stamp
|
||||
*.depend
|
||||
*.vcxproj
|
||||
*.exe
|
||||
*.cache
|
||||
*.lib
|
||||
*.filters
|
||||
*.db
|
||||
*.opendb
|
||||
*.rule
|
||||
*.check_cache
|
||||
*.dll
|
||||
*.list
|
||||
*.json
|
||||
*.ini
|
||||
*.cxx
|
||||
|
||||
.vscode/*
|
@ -0,0 +1,35 @@
|
||||
|
||||
# This is a dummy file, just so CMake does not complain:
|
||||
|
||||
# CMake Error at build/third-party/fastdds/CMakeLists.txt:239 (find_package):
|
||||
# By not providing "Findfoonathan_memory.cmake" in CMAKE_MODULE_PATH this
|
||||
# project has asked CMake to find a package configuration file provided by
|
||||
# "foonathan_memory", but CMake did not find one.
|
||||
#
|
||||
# Could not find a package configuration file provided by "foonathan_memory"
|
||||
# with any of the following names:
|
||||
#
|
||||
# foonathan_memoryConfig.cmake
|
||||
# foonathan_memory-config.cmake
|
||||
#
|
||||
# Add the installation prefix of "foonathan_memory" to CMAKE_PREFIX_PATH or
|
||||
# set "foonathan_memory_DIR" to a directory containing one of the above
|
||||
# files. If "foonathan_memory" provides a separate development package or
|
||||
# SDK, be sure it has been installed.
|
||||
|
||||
# FastDDS requires foonathan_memory and will not find it if we do not provide this
|
||||
# file.
|
||||
#
|
||||
# Since all the variables should already be set by external_foonathan_memory.cmake,
|
||||
# we don't really do anything.
|
||||
|
||||
# This may not be the proper way to do this. But it works...
|
||||
|
||||
|
||||
#message( "In Findfoonathan_memory.cmake" )
|
||||
|
||||
|
||||
#find_package( PkgConfig )
|
||||
#pkg_check_modules( foonathan_memory QUIET foonathan_memory )
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
message(STATUS "Setting Android configurations")
|
||||
message(STATUS "Prepare RealSense SDK for Android OS (${ANDROID_NDK_ABI_NAME})")
|
||||
|
||||
macro(os_set_flags)
|
||||
unset(WIN32)
|
||||
unset(UNIX)
|
||||
unset(APPLE)
|
||||
set(BUILD_UNIT_TESTS OFF)
|
||||
set(BUILD_LEGACY_LIVE_TEST OFF)
|
||||
set(BUILD_EXAMPLES OFF)
|
||||
set(BUILD_TOOLS OFF)
|
||||
set(BUILD_WITH_OPENMP OFF)
|
||||
set(BUILD_GRAPHICAL_EXAMPLES OFF)
|
||||
set(ANDROID_STL "c++_static")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -pedantic -g -D_DEFAULT_SOURCE")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -pedantic -g -Wno-missing-field-initializers")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-multichar")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie")
|
||||
set(HWM_OVER_XU ON)
|
||||
|
||||
if(FORCE_RSUSB_BACKEND)
|
||||
set(BACKEND RS2_USE_ANDROID_BACKEND)
|
||||
set(IMPORT_DEPTH_CAM_FW OFF)
|
||||
else()
|
||||
set(BACKEND RS2_USE_V4L2_BACKEND)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(os_target_config)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
find_library(log-lib log)
|
||||
target_link_libraries(${LRS_TARGET} PRIVATE log)
|
||||
endif()
|
||||
endmacro()
|
@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
project(catch2-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
catch2
|
||||
PREFIX .
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v3.4.0
|
||||
GIT_CONFIG advice.detachedHead=false # otherwise we'll get "You are in 'detached HEAD' state..."
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/third-party/catch2"
|
||||
GIT_SHALLOW 1 # No history needed (requires cmake 3.6)
|
||||
# Override default steps with no action, we just want the clone step.
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
# License: Apache 2.0. See LICENSE file in root directory.
|
||||
# Copyright(c) 2019 Intel Corporation. All Rights Reserved.
|
||||
message(STATUS "Checking internet connection...")
|
||||
file(DOWNLOAD "https://librealsense.intel.com/Releases/connectivity_check" "${CMAKE_CURRENT_BINARY_DIR}/connectivity_check" SHOW_PROGRESS TIMEOUT 5 STATUS status)
|
||||
list (FIND status "\"No error\"" _index)
|
||||
if (${_index} EQUAL -1)
|
||||
message(STATUS "Failed to identify Internet connection")
|
||||
set(INTERNET_CONNECTION OFF)
|
||||
else()
|
||||
message(STATUS "Internet connection identified")
|
||||
set(INTERNET_CONNECTION ON)
|
||||
endif()
|
@ -0,0 +1,15 @@
|
||||
info("Building with CUDA requires CMake v3.8+")
|
||||
cmake_minimum_required(VERSION 3.8.0)
|
||||
enable_language( CUDA )
|
||||
|
||||
find_package(CUDA REQUIRED)
|
||||
|
||||
include_directories(${CUDA_INCLUDE_DIRS})
|
||||
SET(ALL_CUDA_LIBS ${CUDA_LIBRARIES} ${CUDA_cusparse_LIBRARY} ${CUDA_cublas_LIBRARY})
|
||||
SET(LIBS ${LIBS} ${ALL_CUDA_LIBS})
|
||||
|
||||
message(STATUS "CUDA_LIBRARIES: ${CUDA_INCLUDE_DIRS} ${ALL_CUDA_LIBS}")
|
||||
|
||||
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
|
||||
set(CUDA_SEPARABLE_COMPILATION ON)
|
||||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}; -O3 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_62,code=sm_62;")
|
@ -0,0 +1,28 @@
|
||||
file(READ "config/99-realsense-libusb.rules" contents HEX)
|
||||
|
||||
set(UDEV_HEADER "${CMAKE_CURRENT_BINARY_DIR}/udev-rules.h")
|
||||
|
||||
file(WRITE "${UDEV_HEADER}" "#ifndef __UDEV_RULES_H__\n")
|
||||
file(APPEND "${UDEV_HEADER}" "#define __UDEV_RULES_H__\n")
|
||||
file(APPEND "${UDEV_HEADER}" "#ifdef __cplusplus\n")
|
||||
file(APPEND "${UDEV_HEADER}" "extern \"C\" {\n")
|
||||
file(APPEND "${UDEV_HEADER}" "#endif\n")
|
||||
|
||||
file(APPEND "${UDEV_HEADER}" "const char "
|
||||
"realsense_udev_rules[] = {")
|
||||
|
||||
string(LENGTH "${contents}" contents_length)
|
||||
math(EXPR contents_length "${contents_length} - 1")
|
||||
|
||||
foreach(iter RANGE 0 ${contents_length} 2)
|
||||
string(SUBSTRING ${contents} ${iter} 2 line)
|
||||
file(APPEND "${UDEV_HEADER}" "0x${line},")
|
||||
endforeach()
|
||||
|
||||
file(APPEND "${UDEV_HEADER}" "};\n")
|
||||
|
||||
file(APPEND "${UDEV_HEADER}" "#ifdef __cplusplus\n")
|
||||
file(APPEND "${UDEV_HEADER}" "}\n")
|
||||
file(APPEND "${UDEV_HEADER}" "#endif\n")
|
||||
|
||||
file(APPEND "${UDEV_HEADER}" "#endif//\n")
|
@ -0,0 +1,51 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
include(ExternalProject)
|
||||
|
||||
|
||||
# We use a function to enforce a scoped variables creation only for the build
|
||||
# (i.e turn off BUILD_SHARED_LIBS which is used on LRS build as well)
|
||||
function(get_catch2)
|
||||
|
||||
message( STATUS "Fetching Catch2..." )
|
||||
|
||||
# We want to clone the repo and build it here, during configuration, so we can use it.
|
||||
# But ExternalProject_add is limited in that it only does its magic during build.
|
||||
# This is possible in CMake 3.12+ with FetchContent and FetchContent_MakeAvailable in 3.14+ (meaning Ubuntu 20)
|
||||
# but we need to adhere to CMake 3.10 (Ubuntu 18).
|
||||
# So instead, we invoke a new CMake project just to download it:
|
||||
configure_file( CMake/catch2-download.cmake.in
|
||||
${CMAKE_BINARY_DIR}/external-projects/catch2-download/CMakeLists.txt )
|
||||
execute_process( COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/external-projects/catch2-download"
|
||||
OUTPUT_QUIET
|
||||
RESULT_VARIABLE configure_ret )
|
||||
execute_process( COMMAND "${CMAKE_COMMAND}" --build .
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/external-projects/catch2-download"
|
||||
OUTPUT_QUIET
|
||||
RESULT_VARIABLE build_ret )
|
||||
|
||||
if( configure_ret OR build_ret )
|
||||
message( FATAL_ERROR "Failed to download catchorg/catch2" )
|
||||
endif()
|
||||
|
||||
# We use cached variables so the default parameter inside the sub directory will not override the required values
|
||||
# We add "FORCE" so that is a previous cached value is set our assignment will override it.
|
||||
set( CATCH_INSTALL_DOCS OFF CACHE INTERNAL "" FORCE )
|
||||
set( CATCH_INSTALL_EXTRAS OFF CACHE INTERNAL "" FORCE )
|
||||
|
||||
add_subdirectory( "${CMAKE_BINARY_DIR}/third-party/catch2"
|
||||
"${CMAKE_BINARY_DIR}/third-party/catch2/build" )
|
||||
|
||||
# place libraries with other 3rd-party projects
|
||||
set_target_properties( Catch2 Catch2WithMain PROPERTIES
|
||||
FOLDER "3rd Party/catch2" )
|
||||
|
||||
message( STATUS "Fetching Catch2 - Done" )
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
get_catch2()
|
@ -0,0 +1,67 @@
|
||||
cmake_minimum_required(VERSION 3.16.3) # same as in FastDDS (U20)
|
||||
include(FetchContent)
|
||||
|
||||
# We use a function to enforce a scoped variables creation only for FastDDS build (i.e turn off BUILD_SHARED_LIBS which is used on LRS build as well)
|
||||
function(get_fastdds)
|
||||
|
||||
# Mark new options from FetchContent as advanced options
|
||||
mark_as_advanced(FETCHCONTENT_QUIET)
|
||||
mark_as_advanced(FETCHCONTENT_BASE_DIR)
|
||||
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED)
|
||||
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)
|
||||
|
||||
message(CHECK_START "Fetching fastdds...")
|
||||
list(APPEND CMAKE_MESSAGE_INDENT " ") # Indent outputs
|
||||
|
||||
FetchContent_Declare(
|
||||
fastdds
|
||||
GIT_REPOSITORY https://github.com/eProsima/Fast-DDS.git
|
||||
GIT_TAG v2.11.2
|
||||
GIT_SUBMODULES "" # Submodules will be cloned as part of the FastDDS cmake configure stage
|
||||
GIT_SHALLOW ON # No history needed
|
||||
SOURCE_DIR ${CMAKE_BINARY_DIR}/third-party/fastdds
|
||||
)
|
||||
|
||||
# Set FastDDS internal variables
|
||||
# We use cached variables so the default parameter inside the sub directory will not override the required values
|
||||
# We add "FORCE" so that is a previous cached value is set our assignment will override it.
|
||||
set(THIRDPARTY_Asio FORCE CACHE INTERNAL "" FORCE)
|
||||
set(THIRDPARTY_fastcdr FORCE CACHE INTERNAL "" FORCE)
|
||||
set(THIRDPARTY_TinyXML2 FORCE CACHE INTERNAL "" FORCE)
|
||||
set(COMPILE_TOOLS OFF CACHE INTERNAL "" FORCE)
|
||||
set(BUILD_TESTING OFF CACHE INTERNAL "" FORCE)
|
||||
set(SQLITE3_SUPPORT OFF CACHE INTERNAL "" FORCE)
|
||||
#set(ENABLE_OLD_LOG_MACROS OFF CACHE INTERNAL "" FORCE) doesn't work
|
||||
set(FASTDDS_STATISTICS OFF CACHE INTERNAL "" FORCE)
|
||||
|
||||
# Set special values for FastDDS sub directory
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/fastdds/fastdds_install)
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/fastdds/fastdds_install)
|
||||
|
||||
# Get fastdds
|
||||
FetchContent_MakeAvailable(fastdds)
|
||||
|
||||
# Mark new options from FetchContent as advanced options
|
||||
mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FASTDDS)
|
||||
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FASTDDS)
|
||||
|
||||
# place FastDDS project with other 3rd-party projects
|
||||
set_target_properties(fastcdr fastrtps foonathan_memory PROPERTIES
|
||||
FOLDER "3rd Party/fastdds")
|
||||
|
||||
list(POP_BACK CMAKE_MESSAGE_INDENT) # Unindent outputs
|
||||
|
||||
add_library(dds INTERFACE)
|
||||
target_link_libraries( dds INTERFACE fastcdr fastrtps )
|
||||
|
||||
add_definitions(-DBUILD_WITH_DDS)
|
||||
|
||||
install(TARGETS dds EXPORT realsense2Targets)
|
||||
message(CHECK_PASS "Done")
|
||||
endfunction()
|
||||
|
||||
# Trigger the FastDDS build
|
||||
get_fastdds()
|
||||
|
||||
|
@ -0,0 +1,44 @@
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
include(FetchContent)
|
||||
|
||||
# We use a function to enforce a scoped variables creation only for FastDDS build (i.e turn off BUILD_SHARED_LIBS which is used on LRS build as well)
|
||||
function(get_foonathan_memory)
|
||||
|
||||
# Mark new options from FetchContent as advanced options
|
||||
mark_as_advanced(FETCHCONTENT_QUIET)
|
||||
mark_as_advanced(FETCHCONTENT_BASE_DIR)
|
||||
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED)
|
||||
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)
|
||||
|
||||
message(CHECK_START "Fetching foonathan_memory...")
|
||||
list(APPEND CMAKE_MESSAGE_INDENT " ")
|
||||
|
||||
FetchContent_Declare(
|
||||
foonathan_memory
|
||||
GIT_REPOSITORY https://github.com/foonathan/memory.git
|
||||
GIT_TAG "v0.7-3"
|
||||
GIT_SHALLOW ON # No history needed
|
||||
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/foonathan_memory
|
||||
)
|
||||
|
||||
# Always a static library
|
||||
set( BUILD_SHARED_LIBS OFF )
|
||||
|
||||
# Set foonathan_memory variables
|
||||
# These are exposed options; not internal
|
||||
set( FOONATHAN_MEMORY_BUILD_EXAMPLES OFF )
|
||||
set( FOONATHAN_MEMORY_BUILD_TESTS OFF )
|
||||
set( FOONATHAN_MEMORY_BUILD_TOOLS OFF )
|
||||
|
||||
FetchContent_MakeAvailable( foonathan_memory )
|
||||
|
||||
# Mark new options from FetchContent as advanced options
|
||||
mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FOONATHAN_MEMORY)
|
||||
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FOONATHAN_MEMORY)
|
||||
|
||||
list(POP_BACK CMAKE_MESSAGE_INDENT)
|
||||
message(CHECK_PASS "Done")
|
||||
|
||||
endfunction()
|
||||
|
||||
get_foonathan_memory()
|
@ -0,0 +1,50 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
include(ExternalProject)
|
||||
|
||||
|
||||
|
||||
# We use a function to enforce a scoped variables creation only for the build
|
||||
# (i.e turn off BUILD_SHARED_LIBS which is used on LRS build as well)
|
||||
function(get_nlohmann_json)
|
||||
|
||||
message( STATUS #CHECK_START
|
||||
"Fetching nlohmann/json..." )
|
||||
#list( APPEND CMAKE_MESSAGE_INDENT " " ) # Indent outputs
|
||||
|
||||
# We want to clone the json repo and build it here, during configuration, so we can use it.
|
||||
# But ExternalProject_add is limited in that it only does its magic during build.
|
||||
# This is possible in CMake 3.12+ with FetchContent and FetchContent_MakeAvailable in 3.14+ (meaning Ubuntu 20)
|
||||
# but we need to adhere to CMake 3.10 (Ubuntu 18).
|
||||
# So instead, we invoke a new CMake project just to download pybind:
|
||||
configure_file( CMake/json-download.cmake.in
|
||||
${CMAKE_BINARY_DIR}/external-projects/json-download/CMakeLists.txt )
|
||||
execute_process( COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/external-projects/json-download"
|
||||
OUTPUT_QUIET
|
||||
RESULT_VARIABLE configure_ret )
|
||||
execute_process( COMMAND "${CMAKE_COMMAND}" --build .
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/external-projects/json-download"
|
||||
OUTPUT_QUIET
|
||||
RESULT_VARIABLE build_ret )
|
||||
|
||||
if( configure_ret OR build_ret )
|
||||
message( FATAL_ERROR "Failed to download nlohmann/json" )
|
||||
endif()
|
||||
|
||||
add_subdirectory( "${CMAKE_BINARY_DIR}/third-party/json"
|
||||
"${CMAKE_BINARY_DIR}/third-party/json/build" )
|
||||
|
||||
# We cannot directly interface with nlohmann_json (doesn't work on bionic)
|
||||
#install( TARGETS nlohmann_json EXPORT realsense2Targets )
|
||||
|
||||
message( STATUS #CHECK_PASS
|
||||
"Fetching nlohmann/json - Done" )
|
||||
#list( POP_BACK CMAKE_MESSAGE_INDENT ) # Unindent outputs (requires cmake 3.15)
|
||||
|
||||
endfunction()
|
||||
|
||||
# Trigger the build
|
||||
get_nlohmann_json()
|
@ -0,0 +1,60 @@
|
||||
if(CHECK_FOR_UPDATES)
|
||||
include(ExternalProject)
|
||||
message(STATUS "Building libcurl enabled")
|
||||
|
||||
set(CURL_FLAGS -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DUSE_WIN32_LDAP=OFF -DHTTP_ONLY=ON -DCURL_ZLIB=OFF -DCURL_DISABLE_CRYPTO_AUTH=ON -DCMAKE_USE_LIBSSH2=OFF -DBUILD_TESTING=OFF )
|
||||
if (WIN32)
|
||||
set(CURL_FLAGS ${CURL_FLAGS} -DCURL_STATIC_CRT=ON )
|
||||
endif()
|
||||
|
||||
# Add SSL library flag
|
||||
if (WIN32)
|
||||
set(CURL_FLAGS ${CURL_FLAGS} -DCMAKE_USE_SCHANNEL=ON )
|
||||
else()
|
||||
set(CURL_FLAGS ${CURL_FLAGS} -DCMAKE_USE_OPENSSL=ON )
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(
|
||||
libcurl
|
||||
PREFIX libcurl
|
||||
GIT_REPOSITORY "https://github.com/curl/curl.git"
|
||||
GIT_TAG "2f33be817cbce6ad7a36f27dd7ada9219f13584c" # curl-7_75_0
|
||||
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/libcurl
|
||||
CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
|
||||
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
|
||||
-DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}
|
||||
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
|
||||
-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
|
||||
-DCMAKE_CXX_STANDARD_LIBRARIES=${CMAKE_CXX_STANDARD_LIBRARIES}
|
||||
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/libcurl/libcurl_install
|
||||
-DCMAKE_INSTALL_LIBDIR=lib
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
-DANDROID_ABI=${ANDROID_ABI}
|
||||
-DANDROID_STL=${ANDROID_STL} ${CURL_FLAGS}
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
|
||||
set(CURL_DEBUG_TARGET_NAME "libcurl-d")
|
||||
set(CURL_RELEASE_TARGET_NAME "libcurl")
|
||||
add_library(curl INTERFACE)
|
||||
add_definitions(-DCURL_STATICLIB) # Mandatory for building libcurl as static lib
|
||||
|
||||
target_include_directories(curl INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libcurl/libcurl_install/include>)
|
||||
|
||||
target_link_libraries(curl INTERFACE debug ${CMAKE_CURRENT_BINARY_DIR}/libcurl/libcurl_install/lib/${CURL_DEBUG_TARGET_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
target_link_libraries(curl INTERFACE optimized ${CMAKE_CURRENT_BINARY_DIR}/libcurl/libcurl_install/lib/${CURL_RELEASE_TARGET_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
|
||||
# libcurl required libs per OS
|
||||
# (Linux require that the link dependency will be added after the libcurl link target that use it)
|
||||
if (WIN32)
|
||||
target_link_libraries(curl INTERFACE ws2_32.lib crypt32.lib)
|
||||
else()
|
||||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(curl INTERFACE OpenSSL::SSL OpenSSL::Crypto)
|
||||
endif()
|
||||
|
||||
endif() #CHECK_FOR_UPDATES
|
@ -0,0 +1,38 @@
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(
|
||||
libusb
|
||||
|
||||
# Work-around for libusb master broken on Nov 26' 2020 with introduction of v1.0.24
|
||||
# the issue has been reported in https://github.com/libusb/libusb/issues/812
|
||||
GIT_REPOSITORY "https://github.com/ev-mp/libusb.git"
|
||||
GIT_TAG "2a7372db54094a406a755f0b8548b614ba8c78ec" # "v1.0.22" + Mac get_device_list hang fix
|
||||
|
||||
UPDATE_COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/third-party/libusb/CMakeLists.txt
|
||||
${CMAKE_CURRENT_BINARY_DIR}/third-party/libusb/CMakeLists.txt
|
||||
PATCH_COMMAND ""
|
||||
|
||||
SOURCE_DIR "third-party/libusb/"
|
||||
CMAKE_ARGS -DCMAKE_CXX_STANDARD_LIBRARIES=${CMAKE_CXX_STANDARD_LIBRARIES}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DANDROID_ABI=${ANDROID_ABI}
|
||||
-DANDROID_STL=${ANDROID_STL}
|
||||
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/libusb_install
|
||||
TEST_COMMAND ""
|
||||
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/libusb_install/lib/${CMAKE_STATIC_LIBRARY_PREFIX}usb${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
)
|
||||
|
||||
add_library(usb INTERFACE)
|
||||
target_include_directories(usb INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/third-party/libusb/libusb>)
|
||||
target_link_libraries(usb INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/libusb_install/lib/${CMAKE_STATIC_LIBRARY_PREFIX}usb${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(USE_EXTERNAL_USB ON) # INTERFACE libraries can't have real deps, so targets that link with usb need to also depend on libusb
|
||||
|
||||
set_target_properties( libusb PROPERTIES FOLDER "3rd Party")
|
||||
|
||||
if (APPLE)
|
||||
find_library(corefoundation_lib CoreFoundation)
|
||||
find_library(iokit_lib IOKit)
|
||||
target_link_libraries(usb INTERFACE objc ${corefoundation_lib} ${iokit_lib})
|
||||
endif()
|
@ -0,0 +1,142 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
include(ExternalProject)
|
||||
|
||||
|
||||
|
||||
# We use a function to enforce a scoped variables creation only for the build
|
||||
# (i.e turn off BUILD_SHARED_LIBS which is used on LRS build as well)
|
||||
function(get_pybind11)
|
||||
|
||||
message( STATUS #CHECK_START
|
||||
"Fetching pybind11..." )
|
||||
#list( APPEND CMAKE_MESSAGE_INDENT " " ) # Indent outputs
|
||||
|
||||
# We want to clone the pybind repo and build it here, during configuration, so we can use it.
|
||||
# But ExternalProject_add is limited in that it only does its magic during build.
|
||||
# This is possible in CMake 3.12+ with FetchContent and FetchContent_MakeAvailable in 3.14+ (meaning Ubuntu 20)
|
||||
# but we need to adhere to CMake 3.10 (Ubuntu 18).
|
||||
# So instead, we invoke a new CMake project just to download pybind:
|
||||
configure_file( CMake/pybind11-download.cmake.in
|
||||
${CMAKE_BINARY_DIR}/external-projects/pybind11-download/CMakeLists.txt )
|
||||
execute_process( COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/external-projects/pybind11-download"
|
||||
OUTPUT_QUIET
|
||||
RESULT_VARIABLE configure_ret )
|
||||
execute_process( COMMAND "${CMAKE_COMMAND}" --build .
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/external-projects/pybind11-download"
|
||||
OUTPUT_QUIET
|
||||
RESULT_VARIABLE build_ret )
|
||||
|
||||
if( configure_ret OR build_ret )
|
||||
message( FATAL_ERROR "Failed to download pybind11" )
|
||||
endif()
|
||||
|
||||
# Now that it's available, we can refer to it with an actual ExternalProject_add (but notice we're not
|
||||
# downloading anything)
|
||||
ExternalProject_Add( pybind11
|
||||
PREFIX ${CMAKE_BINARY_DIR}/external-projects/pybind11 # just so it doesn't use build/pybind11-prefix
|
||||
SOURCE_DIR ${CMAKE_BINARY_DIR}/third-party/pybind11
|
||||
BINARY_DIR ${CMAKE_BINARY_DIR}/third-party/pybind11/build
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
|
||||
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
# Suppress warnings that are meant for the author of the CMakeLists.txt files
|
||||
-Wno-dev
|
||||
# Just in case!
|
||||
-DPYBIND11_INSTALL=OFF
|
||||
-DPYBIND11_TEST=OFF
|
||||
|
||||
INSTALL_COMMAND ""
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
|
||||
add_subdirectory( "${CMAKE_BINARY_DIR}/third-party/pybind11"
|
||||
"${CMAKE_BINARY_DIR}/third-party/pybind11/build" )
|
||||
|
||||
set_target_properties( pybind11 PROPERTIES FOLDER "3rd Party" )
|
||||
|
||||
# Besides pybind11, any python module will also need to be installed using:
|
||||
# install(
|
||||
# TARGETS ${PROJECT_NAME}
|
||||
# EXPORT pyrealsense2Targets
|
||||
# LIBRARY DESTINATION ${PYTHON_INSTALL_DIR}
|
||||
# ARCHIVE DESTINATION ${PYTHON_INSTALL_DIR}
|
||||
# )
|
||||
# But, to do this, we need to define PYTHON_INSTALL_DIR!
|
||||
if( CMAKE_VERSION VERSION_LESS 3.12 )
|
||||
find_package(PythonInterp REQUIRED)
|
||||
find_package(PythonLibs REQUIRED)
|
||||
set( PYTHON_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/pyrealsense2" CACHE PATH "Installation directory for Python bindings")
|
||||
else()
|
||||
find_package(Python REQUIRED COMPONENTS Interpreter Development)
|
||||
set( PYTHON_INSTALL_DIR "${Python_SITEARCH}/pyrealsense2" CACHE PATH "Installation directory for Python bindings")
|
||||
endif()
|
||||
|
||||
message( STATUS #CHECK_PASS
|
||||
"Fetching pybind11 - Done" )
|
||||
#list( POP_BACK CMAKE_MESSAGE_INDENT ) # Unindent outputs (requires cmake 3.15)
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
# We also want a json-compatible pybind interface:
|
||||
function(get_pybind11_json)
|
||||
|
||||
message( STATUS #CHECK_START
|
||||
"Fetching pybind11_json..." )
|
||||
#list( APPEND CMAKE_MESSAGE_INDENT " " ) # Indent outputs
|
||||
|
||||
# We want to clone the pybind repo and build it here, during configuration, so we can use it.
|
||||
# But ExternalProject_add is limited in that it only does its magic during build.
|
||||
# This is possible in CMake 3.12+ with FetchContent and FetchContent_MakeAvailable in 3.14+ (meaning Ubuntu 20)
|
||||
# but we need to adhere to CMake 3.10 (Ubuntu 18).
|
||||
# So instead, we invoke a new CMake project just to download pybind:
|
||||
configure_file( CMake/pybind11-json-download.cmake.in
|
||||
${CMAKE_BINARY_DIR}/external-projects/pybind11-json-download/CMakeLists.txt )
|
||||
execute_process( COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/external-projects/pybind11-json-download"
|
||||
OUTPUT_QUIET
|
||||
RESULT_VARIABLE configure_ret )
|
||||
execute_process( COMMAND "${CMAKE_COMMAND}" --build .
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/external-projects/pybind11-json-download"
|
||||
OUTPUT_QUIET
|
||||
RESULT_VARIABLE build_ret )
|
||||
|
||||
if( configure_ret OR build_ret )
|
||||
message( FATAL_ERROR "Failed to download pybind11_json" )
|
||||
endif()
|
||||
|
||||
# pybind11_add_module will add the directory automatically (see below)
|
||||
|
||||
message( STATUS #CHECK_PASS
|
||||
"Fetching pybind11_json - Done" )
|
||||
#list( POP_BACK CMAKE_MESSAGE_INDENT ) # Unindent outputs (requires cmake 3.15)
|
||||
|
||||
endfunction()
|
||||
|
||||
# Trigger the build
|
||||
get_pybind11()
|
||||
get_pybind11_json()
|
||||
|
||||
# This function overrides "pybind11_add_module" function, arguments is same as "pybind11_add_module" arguments
|
||||
# pybind11_add_module(<name> SHARED [file, file2, ...] )
|
||||
# Must be declared after pybind11 configuration above
|
||||
function( pybind11_add_module project_name library_type ...)
|
||||
|
||||
# message( STATUS "adding python module --> ${project_name}"
|
||||
|
||||
# "_pybind11_add_module" is calling the origin pybind11 function
|
||||
_pybind11_add_module( ${ARGV})
|
||||
|
||||
# Force Pybind11 not to share pyrealsense2 resources with other pybind modules.
|
||||
# With this definition we force the ABI version to be unique and not risk crashes on different modules.
|
||||
# (workaround for RS5-10582; see also https://github.com/pybind/pybind11/issues/2898)
|
||||
# NOTE: this workaround seems to be needed for debug compilations only
|
||||
target_compile_definitions( ${project_name} PRIVATE -DPYBIND11_COMPILER_TYPE=\"_${project_name}_abi\" )
|
||||
|
||||
target_include_directories( ${project_name} PRIVATE "${CMAKE_BINARY_DIR}/third-party/pybind11-json/include" )
|
||||
|
||||
endfunction()
|
@ -0,0 +1,107 @@
|
||||
# Save the command line compile commands in the build output
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
||||
|
||||
# View the makefile commands during build
|
||||
#set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
# include librealsense helper macros
|
||||
include(CMake/lrs_macros.cmake)
|
||||
include(CMake/version_config.cmake)
|
||||
|
||||
if(ENABLE_CCACHE)
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if(CCACHE_FOUND)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif(CCACHE_FOUND)
|
||||
endif()
|
||||
|
||||
macro(global_set_flags)
|
||||
set(LRS_LIB_NAME ${LRS_TARGET})
|
||||
|
||||
add_definitions(-DELPP_THREAD_SAFE)
|
||||
|
||||
if (BUILD_GLSL_EXTENSIONS)
|
||||
set(LRS_GL_TARGET realsense2-gl)
|
||||
set(LRS_GL_LIB_NAME ${LRS_GL_TARGET})
|
||||
endif()
|
||||
|
||||
if (BUILD_EASYLOGGINGPP)
|
||||
add_definitions(-DBUILD_EASYLOGGINGPP)
|
||||
endif()
|
||||
|
||||
if (ENABLE_EASYLOGGINGPP_ASYNC)
|
||||
add_definitions(-DEASYLOGGINGPP_ASYNC)
|
||||
endif()
|
||||
|
||||
if(TRACE_API)
|
||||
add_definitions(-DTRACE_API)
|
||||
endif()
|
||||
|
||||
if(HWM_OVER_XU)
|
||||
add_definitions(-DHWM_OVER_XU)
|
||||
endif()
|
||||
|
||||
if(COM_MULTITHREADED)
|
||||
add_definitions(-DCOM_MULTITHREADED)
|
||||
endif()
|
||||
|
||||
if (ENFORCE_METADATA)
|
||||
add_definitions(-DENFORCE_METADATA)
|
||||
endif()
|
||||
|
||||
if (BUILD_WITH_CUDA)
|
||||
add_definitions(-DRS2_USE_CUDA)
|
||||
endif()
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_definitions(-DBUILD_SHARED_LIBS)
|
||||
endif()
|
||||
|
||||
if (BUILD_WITH_CUDA)
|
||||
include(CMake/cuda_config.cmake)
|
||||
endif()
|
||||
|
||||
if(BUILD_PYTHON_BINDINGS)
|
||||
include(libusb_config)
|
||||
include(CMake/external_pybind11.cmake)
|
||||
endif()
|
||||
|
||||
if(CHECK_FOR_UPDATES)
|
||||
if (ANDROID_NDK_TOOLCHAIN_INCLUDED)
|
||||
message(STATUS "Android build do not support CHECK_FOR_UPDATES flag, turning it off..")
|
||||
set(CHECK_FOR_UPDATES false)
|
||||
elseif (NOT BUILD_GRAPHICAL_EXAMPLES)
|
||||
message(STATUS "CHECK_FOR_UPDATES depends on BUILD_GRAPHICAL_EXAMPLES flag, turning it off..")
|
||||
set(CHECK_FOR_UPDATES false)
|
||||
else()
|
||||
include(CMake/external_libcurl.cmake)
|
||||
add_definitions(-DCHECK_FOR_UPDATES)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_definitions(-D${BACKEND} -DUNICODE)
|
||||
endmacro()
|
||||
|
||||
macro(global_target_config)
|
||||
target_link_libraries(${LRS_TARGET} PRIVATE realsense-file ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
set_target_properties (${LRS_TARGET} PROPERTIES FOLDER Library)
|
||||
|
||||
target_include_directories(${LRS_TARGET}
|
||||
PRIVATE
|
||||
src
|
||||
${ROSBAG_HEADER_DIRS}
|
||||
${BOOST_INCLUDE_PATH}
|
||||
${LZ4_INCLUDE_PATH}
|
||||
${LIBUSB_LOCAL_INCLUDE_PATH}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
PRIVATE ${USB_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
endmacro()
|
||||
|
@ -0,0 +1,7 @@
|
||||
if(ANDROID_NDK_TOOLCHAIN_INCLUDED)
|
||||
include(CMake/android_config.cmake)
|
||||
elseif (WIN32)
|
||||
include(CMake/windows_config.cmake)
|
||||
else()
|
||||
include(CMake/unix_config.cmake)
|
||||
endif()
|
@ -0,0 +1,51 @@
|
||||
# Set CMAKE_INSTALL_* if not defined
|
||||
set(CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${LRS_TARGET}")
|
||||
|
||||
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/realsense2ConfigVersion.cmake"
|
||||
VERSION ${REALSENSE_VERSION_STRING} COMPATIBILITY AnyNewerVersion)
|
||||
|
||||
configure_package_config_file(CMake/realsense2Config.cmake.in realsense2Config.cmake
|
||||
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
|
||||
INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/bin
|
||||
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
|
||||
)
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||
configure_file(config/librealsense.pc.in config/realsense2.pc @ONLY)
|
||||
|
||||
install(TARGETS ${LRS_TARGET}
|
||||
EXPORT realsense2Targets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/include/librealsense2"
|
||||
)
|
||||
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/librealsense2
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
install(EXPORT realsense2Targets
|
||||
FILE realsense2Targets.cmake
|
||||
NAMESPACE ${LRS_TARGET}::
|
||||
DESTINATION ${CMAKECONFIG_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/realsense2Config.cmake"
|
||||
DESTINATION ${CMAKECONFIG_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/realsense2ConfigVersion.cmake"
|
||||
DESTINATION ${CMAKECONFIG_INSTALL_DIR}
|
||||
)
|
||||
|
||||
# Set library pkgconfig file for facilitating 3rd party integration
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/config/realsense2.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
||||
)
|
||||
|
||||
install(CODE "execute_process(COMMAND ldconfig)")
|
@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
project(nlohmann-json-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
nlohmann_json
|
||||
PREFIX .
|
||||
GIT_REPOSITORY "https://github.com/nlohmann/json.git"
|
||||
GIT_TAG v3.11.3
|
||||
GIT_CONFIG advice.detachedHead=false # otherwise we'll get "You are in 'detached HEAD' state..."
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/third-party/json"
|
||||
GIT_SHALLOW 1 # No history needed (requires cmake 3.6)
|
||||
# Override default steps with no action, we just want the clone step.
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
if (NOT TARGET usb)
|
||||
find_library(LIBUSB_LIB usb-1.0)
|
||||
find_path(LIBUSB_INC libusb.h HINTS PATH_SUFFIXES libusb-1.0)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(usb "libusb not found; using internal version" LIBUSB_LIB LIBUSB_INC)
|
||||
if (USB_FOUND AND NOT USE_EXTERNAL_USB)
|
||||
add_library(usb INTERFACE)
|
||||
target_include_directories(usb INTERFACE ${LIBUSB_INC})
|
||||
target_link_libraries(usb INTERFACE ${LIBUSB_LIB})
|
||||
else()
|
||||
include(CMake/external_libusb.cmake)
|
||||
endif()
|
||||
install(TARGETS usb EXPORT realsense2Targets)
|
||||
endif()
|
@ -0,0 +1,40 @@
|
||||
macro(info msg)
|
||||
message(STATUS "Info: ${msg}")
|
||||
endmacro()
|
||||
|
||||
macro(infoValue variableName)
|
||||
info("${variableName}=\${${variableName}}")
|
||||
endmacro()
|
||||
|
||||
macro(config_cxx_flags)
|
||||
include(CheckCXXCompilerFlag)
|
||||
if(MSVC OR MSVC_IDE)
|
||||
check_cxx_compiler_flag(/std:c++14 SUPPORTS_CXX14)
|
||||
else()
|
||||
check_cxx_compiler_flag(-std=c++14 SUPPORTS_CXX14)
|
||||
endif()
|
||||
if( NOT SUPPORTS_CXX14 )
|
||||
message(FATAL_ERROR "Project '${PROJECT_NAME}' requires C++14 or higher")
|
||||
endif()
|
||||
if( NOT CMAKE_CXX_STANDARD )
|
||||
set( CMAKE_CXX_STANDARD 14 )
|
||||
endif()
|
||||
# We require that the current project (e.g., librealsense) use C++14. However, projects using
|
||||
# the library don't need to be C++14 -- they can use C++11. Hence this is PRIVATE and not PUBLIC:
|
||||
target_compile_features( ${PROJECT_NAME} PRIVATE cxx_std_${CMAKE_CXX_STANDARD} )
|
||||
#set( CMAKE_CUDA_STANDARD ${LRS_CXX_STANDARD} )
|
||||
endmacro()
|
||||
|
||||
macro(config_crt)
|
||||
if(BUILD_WITH_STATIC_CRT)
|
||||
foreach(flag_var
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag_var} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endif(${flag_var} MATCHES "/MD")
|
||||
endforeach(flag_var)
|
||||
endif(BUILD_WITH_STATIC_CRT)
|
||||
endmacro()
|
@ -0,0 +1,51 @@
|
||||
option(ENABLE_CCACHE "Build with ccache." ON)
|
||||
option(BUILD_WITH_CUDA "Enable CUDA" OFF)
|
||||
option(BUILD_GLSL_EXTENSIONS "Build GLSL extensions API" ON)
|
||||
option(BUILD_WITH_OPENMP "Use OpenMP" OFF)
|
||||
option(BUILD_EASYLOGGINGPP "Build EasyLogging++ as a part of the build" ON)
|
||||
option(BUILD_WITH_STATIC_CRT "Build with static link CRT" ON)
|
||||
option(HWM_OVER_XU "Send HWM commands over UVC XU control" ON)
|
||||
option(COM_MULTITHREADED "Set OFF to initialize COM library with COINIT_APARTMENTTHREADED (Windows only)" ON)
|
||||
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
||||
option(BUILD_UNIT_TESTS "Build LibCI unit tests. If enabled, additional test data may be downloaded" OFF)
|
||||
option(BUILD_LEGACY_LIVE_TEST "Build the live-test.exe test used in Travis. If enabled, additional test data may be downloaded" OFF)
|
||||
option(BUILD_EXAMPLES "Build examples (not including graphical examples -- see BUILD_GRAPHICAL_EXAMPLES)" ON)
|
||||
option(BUILD_GRAPHICAL_EXAMPLES "Build graphical examples (Viewer & DQT) -- Implies BUILD_GLSL_EXTENSIONS" ON)
|
||||
option(BUILD_CV_EXAMPLES "Build OpenCV examples" OFF)
|
||||
option(BUILD_DLIB_EXAMPLES "Build DLIB examples - requires DLIB_DIR" OFF)
|
||||
option(BUILD_PCL_EXAMPLES "Build PCL examples" OFF)
|
||||
option(BUILD_TOOLS "Build tools (fw-updater, etc.) that are not examples" ON)
|
||||
option(ENFORCE_METADATA "Require WinSDK with Metadata support during compilation. Windows OS Only" OFF)
|
||||
option(BUILD_PYTHON_BINDINGS "Build Python bindings" OFF)
|
||||
option(BUILD_LEGACY_PYBACKEND "Build deprecated Python backend bindings" OFF)
|
||||
option(BUILD_PYTHON_DOCS "Build Documentation for Python bindings" OFF)
|
||||
option(BUILD_CSHARP_BINDINGS "Build C# bindings" OFF)
|
||||
option(BUILD_MATLAB_BINDINGS "Build Matlab bindings" OFF)
|
||||
option(BUILD_UNITY_BINDINGS "Copy the unity project to the build folder with the required dependencies" OFF)
|
||||
option(BUILD_OPENVINO_EXAMPLES "Build Intel OpenVINO Toolkit examples - requires INTEL_OPENVINO_DIR" OFF)
|
||||
option(BUILD_OPEN3D_EXAMPLES "Build Open3D examples" OFF)
|
||||
option(BUILD_OPENNI2_BINDINGS "Build OpenNI bindings" OFF)
|
||||
option(IMPORT_DEPTH_CAM_FW "Download the latest firmware for the depth cameras" ON)
|
||||
option(BUILD_CV_KINFU_EXAMPLE "Build OpenCV KinectFusion example" OFF)
|
||||
option(FORCE_RSUSB_BACKEND "Use RS USB backend, mandatory for Win7/MacOS/Android, optional for Linux" OFF)
|
||||
option(FORCE_LIBUVC "Explicitly turn-on libuvc backend - deprecated, use FORCE_RSUSB_BACKEND instead" OFF)
|
||||
option(FORCE_WINUSB_UVC "Explicitly turn-on winusb_uvc (for win7) backend - deprecated, use FORCE_RSUSB_BACKEND instead" OFF)
|
||||
option(ANDROID_USB_HOST_UVC "Build UVC backend for Android - deprecated, use FORCE_RSUSB_BACKEND instead" OFF)
|
||||
# This feature requires OpenSSL installation on Linux/OSX, OSX normally does not come with OpenSSL integrated(Thats why default is OFF on OSX)
|
||||
if (NOT APPLE)
|
||||
option(CHECK_FOR_UPDATES "Checks for versions updates" ON)
|
||||
else()
|
||||
option(CHECK_FOR_UPDATES "Checks for versions updates" OFF)
|
||||
endif()
|
||||
option(BUILD_WITH_CPU_EXTENSIONS "Enable compiler optimizations using CPU extensions (such as AVX)" ON)
|
||||
set(UNIT_TESTS_ARGS "" CACHE STRING "Command-line arguments to pass to unit-tests-config.py, e.g. '-t <tag> -r <regex>'")
|
||||
#Performance improvement with Ubuntu 18/20
|
||||
if(UNIX AND (NOT ANDROID_NDK_TOOLCHAIN_INCLUDED))
|
||||
option(ENABLE_EASYLOGGINGPP_ASYNC "Switch Logger to Asynchronous Mode (set OFF for Synchronous Mode)" ON)
|
||||
else()
|
||||
option(ENABLE_EASYLOGGINGPP_ASYNC "Switch Logger to Asynchronous Mode (set OFF for Synchronous Mode)" OFF)
|
||||
endif()
|
||||
option(BUILD_PC_STITCHING "Build pointcloud-stitching example" OFF)
|
||||
option(BUILD_WITH_DDS "Access camera devices through DDS topics (requires CMake 3.16.3)" OFF)
|
||||
option(BUILD_RS2_ALL "Build realsense2-all static bundle containing all realsense libraries (with BUILD_SHARED_LIBS=OFF)" ON)
|
||||
|
@ -0,0 +1,7 @@
|
||||
# The NEW policy flag set OpenGL_GL_PREFERENCE variable to GLVND.
|
||||
if (POLICY CMP0072)
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
endif()
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
set(DEPENDENCIES realsense2 glfw ${OPENGL_LIBRARIES})
|
@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
project(pybind11-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
pybind11
|
||||
PREFIX .
|
||||
GIT_REPOSITORY "https://github.com/pybind/pybind11.git"
|
||||
GIT_TAG v2.10.3
|
||||
GIT_CONFIG advice.detachedHead=false # otherwise we'll get "You are in 'detached HEAD' state..."
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/third-party/pybind11"
|
||||
GIT_SHALLOW ON # No history needed (requires cmake 3.6)
|
||||
# Override default steps with no action, we just want the clone step.
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
project(pybind11-json-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
pybind11_json
|
||||
PREFIX .
|
||||
GIT_REPOSITORY "https://github.com/pybind/pybind11_json.git"
|
||||
GIT_TAG 0.2.13
|
||||
GIT_CONFIG advice.detachedHead=false # otherwise we'll get "You are in 'detached HEAD' state..."
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/third-party/pybind11-json"
|
||||
GIT_SHALLOW ON # No history needed (requires cmake 3.6)
|
||||
# Override default steps with no action, we just want the clone step.
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set(pyrealsense2_VERSION_MAJOR "@REALSENSE_VERSION_MAJOR@")
|
||||
set(pyrealsense2_VERSION_MINOR "@REALSENSE_VERSION_MINOR@")
|
||||
set(pyrealsense2_VERSION_PATCH "@REALSENSE_VERSION_PATCH@")
|
||||
|
||||
set(pyrealsense2_VERSION ${realsense2_VERSION_MAJOR}.${realsense2_VERSION_MINOR}.${realsense2_VERSION_PATCH})
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/pyrealsense2Targets.cmake")
|
||||
set(realsense2_LIBRARY pyrealsense2::pyrealsense2)
|
@ -0,0 +1,12 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set(realsense2-gl_VERSION_MAJOR "@REALSENSE_VERSION_MAJOR@")
|
||||
set(realsense2-gl_VERSION_MINOR "@REALSENSE_VERSION_MINOR@")
|
||||
set(realsense2-gl_VERSION_PATCH "@REALSENSE_VERSION_PATCH@")
|
||||
|
||||
set(realsense2-gl_VERSION ${realsense2-gl_VERSION_MAJOR}.${realsense2-gl_VERSION_MINOR}.${realsense2-gl_VERSION_PATCH})
|
||||
|
||||
set_and_check(realsense2-gl_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/realsense2-glTargets.cmake")
|
||||
set(realsense2-gl_LIBRARY realsense2-gl::realsense2-gl)
|
@ -0,0 +1,12 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set(realsense2-net_VERSION_MAJOR "@REALSENSE_VERSION_MAJOR@")
|
||||
set(realsense2-net_VERSION_MINOR "@REALSENSE_VERSION_MINOR@")
|
||||
set(realsense2-net_VERSION_PATCH "@REALSENSE_VERSION_PATCH@")
|
||||
|
||||
set(realsense2-net_VERSION ${realsense2-net_VERSION_MAJOR}.${realsense2-net_VERSION_MINOR}.${realsense2-gl_VERSION_PATCH})
|
||||
|
||||
set_and_check(realsense2-net_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/realsense2-netTargets.cmake")
|
||||
set(realsense2-net_LIBRARY realsense2-net::realsense2-net)
|
@ -0,0 +1,12 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set(realsense2_VERSION_MAJOR "@REALSENSE_VERSION_MAJOR@")
|
||||
set(realsense2_VERSION_MINOR "@REALSENSE_VERSION_MINOR@")
|
||||
set(realsense2_VERSION_PATCH "@REALSENSE_VERSION_PATCH@")
|
||||
|
||||
set(realsense2_VERSION ${realsense2_VERSION_MAJOR}.${realsense2_VERSION_MINOR}.${realsense2_VERSION_PATCH})
|
||||
|
||||
set_and_check(realsense2_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/realsense2Targets.cmake")
|
||||
set(realsense2_LIBRARY realsense2::realsense2)
|
@ -0,0 +1,59 @@
|
||||
message(STATUS "Setting Unix configurations")
|
||||
|
||||
macro(os_set_flags)
|
||||
|
||||
# Put all the collaterals together, so we can find when trying to run examples/tests
|
||||
# Note: this puts the outputs under <binary>/<build-type>
|
||||
if( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
|
||||
# This can happen according to the docs -- and in GHA...
|
||||
message( STATUS "No output directory set; using ${CMAKE_BINARY_DIR}/Release/" )
|
||||
set( CMAKE_BUILD_TYPE "Release" )
|
||||
endif()
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -D_DEFAULT_SOURCE")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-missing-field-initializers")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-multichar -Wsequence-point -Wformat -Wformat-security")
|
||||
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE MACHINE)
|
||||
if(${MACHINE} MATCHES "arm-*")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon -mfloat-abi=hard -ftree-vectorize -latomic")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -mfloat-abi=hard -ftree-vectorize -latomic")
|
||||
elseif(${MACHINE} MATCHES "aarch64-*")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mstrict-align -ftree-vectorize")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstrict-align -ftree-vectorize")
|
||||
elseif(${MACHINE} MATCHES "powerpc64(le)?-linux-gnu")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftree-vectorize")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftree-vectorize")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mssse3")
|
||||
set(LRS_TRY_USE_AVX true)
|
||||
endif(${MACHINE} MATCHES "arm-*")
|
||||
|
||||
if(BUILD_WITH_OPENMP)
|
||||
find_package(OpenMP REQUIRED)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(FORCE_RSUSB_BACKEND ON)
|
||||
endif()
|
||||
|
||||
if(FORCE_RSUSB_BACKEND)
|
||||
set(BACKEND RS2_USE_LIBUVC_BACKEND)
|
||||
else()
|
||||
set(BACKEND RS2_USE_V4L2_BACKEND)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(os_target_config)
|
||||
endmacro()
|
@ -0,0 +1,28 @@
|
||||
##################################################################
|
||||
# Parse librealsense version and assign it to CMake variables #
|
||||
# This function parses librealsense public API header file, rs.h #
|
||||
# and retrieves version numbers embedded in the source code. #
|
||||
# Since the function relies on hard-coded variables, it is prone #
|
||||
# for failures should these constants be modified in future #
|
||||
##################################################################
|
||||
function(assign_version_property VER_COMPONENT)
|
||||
file(STRINGS "./include/librealsense2/rs.h" REALSENSE_VERSION_${VER_COMPONENT} REGEX "#define RS2_API_${VER_COMPONENT}_VERSION")
|
||||
separate_arguments(REALSENSE_VERSION_${VER_COMPONENT})
|
||||
list(GET REALSENSE_VERSION_${VER_COMPONENT} -1 tmp)
|
||||
if (tmp LESS 0)
|
||||
message( FATAL_ERROR "Could not obtain valid Librealsense version ${VER_COMPONENT} component - actual value is ${tmp}" )
|
||||
endif()
|
||||
set(REALSENSE_VERSION_${VER_COMPONENT} ${tmp} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(REALSENSE_VERSION_MAJOR -1)
|
||||
set(REALSENSE_VERSION_MINOR -1)
|
||||
set(REALSENSE_VERSION_PATCH -1)
|
||||
assign_version_property(MAJOR)
|
||||
assign_version_property(MINOR)
|
||||
assign_version_property(PATCH)
|
||||
set(REALSENSE_VERSION_STRING ${REALSENSE_VERSION_MAJOR}.${REALSENSE_VERSION_MINOR}.${REALSENSE_VERSION_PATCH})
|
||||
infoValue(REALSENSE_VERSION_STRING)
|
||||
if (BUILD_GLSL_EXTENSIONS)
|
||||
set(REALSENSE-GL_VERSION_STRING ${REALSENSE_VERSION_MAJOR}.${REALSENSE_VERSION_MINOR}.${REALSENSE_VERSION_PATCH})
|
||||
endif()
|
@ -0,0 +1,102 @@
|
||||
message(STATUS "Setting Windows configurations")
|
||||
cmake_minimum_required(VERSION 3.6.0) #Required by list(FILTER ...
|
||||
config_crt()
|
||||
|
||||
macro(os_set_flags)
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
# Put all the collaterals together, so we can find when trying to run examples/tests
|
||||
# Note: this puts the outputs under <binary>/<build-type>
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
if(BUILD_WITH_OPENMP)
|
||||
find_package(OpenMP REQUIRED)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
|
||||
endif()
|
||||
|
||||
## Check for Windows Version ##
|
||||
if(${CMAKE_SYSTEM_VERSION} EQUAL 6.1) # Windows 7
|
||||
set(FORCE_RSUSB_BACKEND ON)
|
||||
endif()
|
||||
|
||||
if(FORCE_RSUSB_BACKEND)
|
||||
set(BACKEND RS2_USE_WINUSB_UVC_BACKEND)
|
||||
else()
|
||||
set(BACKEND RS2_USE_WMF_BACKEND)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# Set CMAKE_DEBUG_POSTFIX to "d" to add a trailing "d" to library
|
||||
# built in debug mode. In this Windows user can compile, build and install the
|
||||
# library in both Release and Debug configuration avoiding naming clashes in the
|
||||
# installation directories.
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
# build with multiple cores
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /wd4819")
|
||||
set(LRS_TRY_USE_AVX true)
|
||||
add_definitions(-D_UNICODE)
|
||||
endif()
|
||||
set(DOTNET_VERSION_LIBRARY "3.5" CACHE STRING ".Net Version, defaulting to '3.5', the Unity wrapper currently supports only .NET 3.5")
|
||||
set(DOTNET_VERSION_EXAMPLES "4.0" CACHE STRING ".Net Version, defaulting to '4.0'")
|
||||
|
||||
# Windows.h will define the min/max macros which will
|
||||
# collide with std's min/max templates, which we want to use.
|
||||
add_definitions(-DNOMINMAX)
|
||||
endmacro()
|
||||
|
||||
macro(os_target_config)
|
||||
add_definitions(-D__SSSE3__ -D_CRT_SECURE_NO_WARNINGS)
|
||||
|
||||
if(FORCE_RSUSB_BACKEND)
|
||||
if (NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
message("Preparing Windows 7 drivers" )
|
||||
make_directory(${CMAKE_CURRENT_BINARY_DIR}/drivers/)
|
||||
file(GLOB DRIVERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/win7/drivers/" "${CMAKE_CURRENT_SOURCE_DIR}/src/win7/drivers/*")
|
||||
foreach(item IN LISTS DRIVERS)
|
||||
message("Copying ${CMAKE_CURRENT_SOURCE_DIR}/src/win7/drivers/${item} to ${CMAKE_CURRENT_BINARY_DIR}/drivers/" )
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/win7/drivers/${item}" "${CMAKE_CURRENT_BINARY_DIR}/drivers/${item}" COPYONLY)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
add_custom_target(realsense-driver ALL DEPENDS ${DRIVERS})
|
||||
add_dependencies(${LRS_TARGET} realsense-driver)
|
||||
set_target_properties (realsense-driver PROPERTIES FOLDER Library)
|
||||
endif()
|
||||
|
||||
get_target_property(LRS_FILES ${LRS_TARGET} SOURCES)
|
||||
list(APPEND LRS_HEADERS ${LRS_FILES})
|
||||
list(APPEND LRS_SOURCES ${LRS_FILES})
|
||||
list(FILTER LRS_HEADERS INCLUDE REGEX ".\\.h$|.\\.hpp$|.\\.def$|.\\.cuh$")
|
||||
list(FILTER LRS_SOURCES INCLUDE REGEX ".\\.c$|.\\.cpp$|.\\.cc$|.\\.cu$")
|
||||
|
||||
foreach(_file IN ITEMS ${LRS_HEADERS})
|
||||
string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" _relative_file ${_file})
|
||||
get_filename_component(_file_path "${_relative_file}" PATH)
|
||||
string(REPLACE "/" "\\" _file_path_msvc "${_file_path}")
|
||||
source_group("Header Files\\${_file_path_msvc}" FILES "${_relative_file}")
|
||||
endforeach()
|
||||
|
||||
foreach(_file IN ITEMS ${LRS_SOURCES})
|
||||
string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" _relative_file ${_file})
|
||||
get_filename_component(_file_path "${_relative_file}" PATH)
|
||||
string(REPLACE "/" "\\" _file_path_msvc "${_file_path}")
|
||||
source_group("Source Files\\${_file_path_msvc}" FILES "${_relative_file}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
#modify variable with prefix. Mimics list(TRANSFORM ... PREPEND introduced with cmake 3.12
|
||||
FUNCTION(PREPEND var prefix)
|
||||
SET(listVar "")
|
||||
FOREACH(f ${ARGN})
|
||||
LIST(APPEND listVar "${prefix}/${f}")
|
||||
ENDFOREACH(f)
|
||||
SET(${var} "${listVar}" PARENT_SCOPE)
|
||||
ENDFUNCTION(PREPEND)
|
@ -0,0 +1,118 @@
|
||||
|
||||
# Xenial requires 3.5, Bionic 3.10...
|
||||
cmake_minimum_required(VERSION 3.1.0)
|
||||
|
||||
set( LRS_TARGET realsense2 )
|
||||
project( ${LRS_TARGET} LANGUAGES CXX C )
|
||||
|
||||
# Allow librealsense2 and all of the nested project to include the main repo folder
|
||||
set(REPO_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${REPO_ROOT})
|
||||
|
||||
include(CMake/lrs_options.cmake)
|
||||
include(CMake/connectivity_check.cmake)
|
||||
#Deprecation message, should be removed in future releases
|
||||
if(${FORCE_LIBUVC} OR ${FORCE_WINUSB_UVC} OR ${ANDROID_USB_HOST_UVC})
|
||||
MESSAGE(DEPRECATION "FORCE_LIBUVC, FORCE_WINUSB_UVC and ANDROID_USB_HOST_UVC are deprecated, use FORCE_RSUSB_BACKEND instead")
|
||||
set(FORCE_RSUSB_BACKEND ON)
|
||||
endif()
|
||||
|
||||
# Checking Internet connection, as DEPTH CAM needs to download the FW from amazon cloud
|
||||
if(IMPORT_DEPTH_CAM_FW AND NOT INTERNET_CONNECTION)
|
||||
message(WARNING "No internet connection, disabling IMPORT_DEPTH_CAM_FW")
|
||||
set(IMPORT_DEPTH_CAM_FW OFF)
|
||||
endif()
|
||||
|
||||
if (BUILD_PC_STITCHING AND NOT BUILD_GLSL_EXTENSIONS)
|
||||
MESSAGE(STATUS "BUILD_PC_STITCHING explicitely depends on BUILD_GLSL_EXTENSIONS, set it ON")
|
||||
SET(BUILD_GLSL_EXTENSIONS ON)
|
||||
endif()
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake)
|
||||
|
||||
# include librealsense general configuration
|
||||
include(CMake/global_config.cmake)
|
||||
|
||||
# include os specific macros
|
||||
# macro definition located at "CMake/global_config.cmake"
|
||||
include(CMake/include_os.cmake)
|
||||
|
||||
# set os specific configuration flags
|
||||
# macro definition located at "CMake/<OS>_config.cmake"
|
||||
os_set_flags()
|
||||
|
||||
# set global configuration flags
|
||||
# macro definition located at "CMake/global_config.cmake"
|
||||
global_set_flags()
|
||||
|
||||
# If no type is given explicitly the type is STATIC or SHARED based on whether the current value of the variable [BUILD_SHARED_LIBS](https://cmake.org/cmake/help/v3.10/variable/BUILD_SHARED_LIBS.html#variable:BUILD_SHARED_LIBS) is ON
|
||||
add_library(${LRS_TARGET})
|
||||
|
||||
config_cxx_flags()
|
||||
|
||||
# set library version
|
||||
set_target_properties(${LRS_TARGET} PROPERTIES VERSION ${REALSENSE_VERSION_STRING} SOVERSION "${REALSENSE_VERSION_MAJOR}.${REALSENSE_VERSION_MINOR}")
|
||||
|
||||
include(include/CMakeLists.txt)
|
||||
include(src/CMakeLists.txt)
|
||||
include(third-party/CMakeLists.txt)
|
||||
|
||||
target_link_libraries( ${LRS_TARGET} PUBLIC rsutils )
|
||||
|
||||
if(BUILD_WITH_DDS)
|
||||
if (CMAKE_SYSTEM MATCHES "Windows" OR CMAKE_SYSTEM MATCHES "Linux")
|
||||
|
||||
message(STATUS "Building with FastDDS")
|
||||
include(CMake/external_foonathan_memory.cmake)
|
||||
include(CMake/external_fastdds.cmake)
|
||||
|
||||
target_link_libraries( ${LRS_TARGET} PRIVATE realdds )
|
||||
|
||||
else()
|
||||
MESSAGE(STATUS "Turning off `BUILD_WITH_DDS` as it's only supported on Windows & Linux and not on ${CMAKE_SYSTEM}")
|
||||
set(BUILD_WITH_DDS OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# configure the project according to OS specific requirments
|
||||
# macro definition located at "CMake/<OS>_config.cmake"
|
||||
os_target_config()
|
||||
|
||||
# global project configuration
|
||||
# macro definition located at "CMake/global_config.cmake"
|
||||
global_target_config()
|
||||
|
||||
include(CMake/install_config.cmake)
|
||||
|
||||
add_subdirectory(wrappers)
|
||||
if ( ( BUILD_EXAMPLES OR BUILD_PC_STITCHING ) AND BUILD_GLSL_EXTENSIONS )
|
||||
find_package(glfw3 3.3 QUIET)
|
||||
if(NOT TARGET glfw)
|
||||
message(STATUS "GLFW 3.3 not found; using internal version")
|
||||
set(GLFW_INSTALL ON CACHE BOOL "" FORCE)
|
||||
add_subdirectory(third-party/glfw)
|
||||
endif()
|
||||
add_subdirectory(src/gl)
|
||||
endif()
|
||||
|
||||
if(BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
add_subdirectory(tools)
|
||||
elseif(BUILD_TOOLS)
|
||||
add_subdirectory(tools)
|
||||
endif()
|
||||
|
||||
if(BUILD_UNIT_TESTS OR BUILD_LEGACY_LIVE_TEST)
|
||||
include( CMake/external_catch2.cmake )
|
||||
add_subdirectory(unit-tests)
|
||||
endif()
|
||||
|
||||
if(IMPORT_DEPTH_CAM_FW)
|
||||
add_subdirectory(common/fw)
|
||||
endif()
|
||||
|
||||
include(CMake/embedd_udev_rules.cmake)
|
||||
|
||||
if( BUILD_RS2_ALL )
|
||||
include( src/realsense2-all.cmake )
|
||||
endif()
|
@ -0,0 +1,72 @@
|
||||
# How to Contribute
|
||||
|
||||
This project welcomes third-party code via GitHub pull requests.
|
||||
|
||||
You are welcome to propose and discuss enhancements using project [issues](https://github.com/IntelRealSense/librealsense/issues).
|
||||
|
||||
> **Branching Policy**:
|
||||
> The `master` branch is considered stable, at all times.
|
||||
> The `development` branch is the one where all contributions must be merged before being promoted to master.
|
||||
> If you plan to propose a patch, please commit into the `development` branch, or its own feature branch.
|
||||
|
||||
We recommend enabling [Github Actions](https://docs.github.com/en/actions) on your fork of `librealsense` to make sure the changes compile on all platforms and pass unit-tests.
|
||||
|
||||
In addition, please run `pr_check.sh` and `api_check.sh` under `scripts` directory. These scripts verify compliance with project's standards:
|
||||
|
||||
1. Every example / source file must refer to [LICENSE](https://github.com/IntelRealSense/librealsense/blob/master/LICENSE)
|
||||
2. Every example / source file must include correct copyright notice
|
||||
3. For indentation we are using spaces and not tabs
|
||||
4. Line-endings must be Unix and not DOS style
|
||||
5. Every API header file must be able to compile as the first included header (no implicit dependencies)
|
||||
|
||||
Most common issues can be automatically resolved by running `./pr_check.sh --fix`
|
||||
|
||||
Please familirize yourself with the [Apache License 2.0](https://github.com/IntelRealSense/librealsense/blob/master/LICENSE) before contributing.
|
||||
|
||||
## Step-by-Step
|
||||
|
||||
1. Make sure you have `git` and `cmake` installed on your system. On Windows we recommend using [Git Extensions](https://github.com/gitextensions/gitextensions/releases) for git bash.
|
||||
2. Run `git clone https://github.com/IntelRealSense/librealsense.git` and `cd librealsense`
|
||||
3. To align with latest status of the development branch, run:
|
||||
```
|
||||
git fetch origin
|
||||
git checkout development
|
||||
git reset --hard origin/development
|
||||
```
|
||||
4. `git checkout -b name_of_your_contribution` to create a dedicated branch
|
||||
5. Make your changes to the local repository
|
||||
6. Make sure your local git user is updated, or run `git config --global user.email "email@example.com"` and `git config --global user.user "user"` to set it up. This is the user & email that will appear in GitHub history.
|
||||
7. `git add -p` to select the changes you wish to add
|
||||
8. `git commit -m "Description of the change"`
|
||||
9. Make sure you have a GitHub user and [fork librealsense](https://github.com/IntelRealSense/librealsense#fork-destination-box)
|
||||
10. `git remote add fork https://github.com/username/librealsense.git` with your GitHub `username`
|
||||
11. `git fetch fork`
|
||||
12. `git push fork` to push `name_of_your_contribution` branch to your fork
|
||||
13. Go to your fork on GitHub at `https://github.com/username/librealsense`
|
||||
14. Click the `New pull request` button
|
||||
15. For `base` combo-box select `development`, since you want to submit a PR to that branch
|
||||
16. For `compare` combo-box select `name_of_your_contribution` with your commit
|
||||
17. Review your changes and click `Create pull request`
|
||||
18. Wait for all automated checks to pass
|
||||
19. The PR will be approved / rejected after review from the team and the community
|
||||
|
||||
To continue to new change, goto step 3.
|
||||
To return to your PR (in order to make more changes):
|
||||
1. `git stash`
|
||||
2. `git checkout name_of_your_contribution`
|
||||
3. Repeat items 5-8 from the previous list
|
||||
4. `git push fork`
|
||||
The pull request will be automatically updated
|
||||
|
||||
## Comment about the Wrappers
|
||||
|
||||
> It is very time consuming (and often impossible) for a single developer to test contributed functionality using all of the supported [wrappers](https://github.com/IntelRealSense/librealsense/tree/master/wrappers). There is no expectation of adding new functionality to all of the wrappers. One noteable exception is maintaining parity of public enumerations. Without strict maintanance it is easy for these lists to go out of sync and this can have serious runtime consequences.
|
||||
|
||||
For example, when adding new value to [`rs2_option`](https://github.com/IntelRealSense/librealsense/blob/master/include/librealsense2/h/rs_option.h) enum, please also add it to:
|
||||
1. The list of Matlab options under [`wrappers/matlab/option.m`](https://github.com/IntelRealSense/librealsense/blob/master/wrappers/matlab/option.m#L3-L46)
|
||||
2. The list of options for [Unreal Engine](https://github.com/IntelRealSense/librealsense/blob/v2.32.1/wrappers/unrealengine4/Plugins/RealSense/Source/RealSense/Public/RealSenseTypes.h#L56-L118) integration
|
||||
3. The list of options in the C# wrapper - [`wrappers/csharp/Intel.RealSense/Types/Enums/Option.cs`](https://github.com/IntelRealSense/librealsense/blob/v2.32.1/wrappers/csharp/Intel.RealSense/Types/Enums/Option.cs)
|
||||
4. The list of Java options used for Android integration - [`wrappers/android/librealsense/src/main/java/com/intel/realsense/librealsense/Option.java`](https://github.com/IntelRealSense/librealsense/blob/v2.32.1/wrappers/android/librealsense/src/main/java/com/intel/realsense/librealsense/Option.java#L4-L64)
|
||||
5. The list of options in the [python](https://github.com/IntelRealSense/librealsense/blob/v2.32.1/wrappers/python/pybackend.cpp#L102-L165) wrapper
|
||||
|
||||
Once all are updated [Github Actions](https://docs.github.com/en/actions) will give clear indication that each of the wrappers is still passing compilation.
|
@ -0,0 +1,7 @@
|
||||
Copyright (2017-2024), Intel Corporation.
|
||||
This "Software" is furnished under license and may only be used or copied in accordance with the terms of that license.
|
||||
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted by this document.
|
||||
The Software is subject to change without notice, and should not be construed as a commitment by Intel Corporation to market, license, sell or support any product or technology.
|
||||
Unless otherwise provided for in the license under which this Software is provided, the Software is provided AS IS, with no warranties of any kind, express or implied.
|
||||
Except as expressly permitted by the Software license, neither Intel Corporation nor its suppliers assumes any responsibility or liability for any errors or inaccuracies that may appear herein.
|
||||
Except as expressly permitted by the Software license, no part of the Software may be reproduced, stored in a retrieval system, transmitted in any form, or distributed by any means without the express written consent of Intel Corporation.
|
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2017 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this project except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
||||
# Security Policy
|
||||
Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
Please report any security vulnerabilities in this project [utilizing the guidelines here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html).
|
||||
|
@ -0,0 +1,34 @@
|
||||
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
MESSAGE(WARNING "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
MESSAGE(STATUS "Uninstall targets will be skipped")
|
||||
ELSE(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
STRING(REGEX REPLACE "\n" ";" files "${files}")
|
||||
FOREACH(file ${files})
|
||||
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||
IF(EXISTS "$ENV{DESTDIR}${file}")
|
||||
EXEC_PROGRAM(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
IF(NOT "${rm_retval}" STREQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
ENDIF(NOT "${rm_retval}" STREQUAL 0)
|
||||
ELSEIF(NOT "${CMAKE_VERSION}" STRLESS "2.8.1")
|
||||
IF(IS_SYMLINK "$ENV{DESTDIR}${file}")
|
||||
EXEC_PROGRAM(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
IF(NOT "${rm_retval}" STREQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
ENDIF(NOT "${rm_retval}" STREQUAL 0)
|
||||
ENDIF(IS_SYMLINK "$ENV{DESTDIR}${file}")
|
||||
ELSE(EXISTS "$ENV{DESTDIR}${file}")
|
||||
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
|
||||
ENDFOREACH(file)
|
||||
execute_process(COMMAND ldconfig)
|
||||
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
@ -0,0 +1,77 @@
|
||||
# librealsense Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at [sergey.dorodnicov@intel.com](mailto://sergey.dorodnicov@intel.com). All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
|
@ -0,0 +1,84 @@
|
||||
# License: Apache 2.0. See LICENSE file in root directory.
|
||||
# Copyright(c) 2019 Intel Corporation. All Rights Reserved.
|
||||
|
||||
set(COMMON_SRC
|
||||
"${CMAKE_CURRENT_LIST_DIR}/animated.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/float2.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/float3.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/float4.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/matrix4.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/plane.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/rect.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/rendering.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/model-views.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/model-views.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/notifications.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/notifications.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/calibration-model.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/calibration-model.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/viewer.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/viewer.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ux-window.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ux-window.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ux-alignment.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ux-alignment.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/opengl3.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/opengl3.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/rs-config.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/rs-config.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/os.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/os.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/fw-update-helper.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/fw-update-helper.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/metadata-helper.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/metadata-helper.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/output-model.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/output-model.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/skybox.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/skybox.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/measurement.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/measurement.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/on-chip-calib.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/on-chip-calib.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/updates-model.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/updates-model.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/option-model.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/option-model.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/device-model.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/device-model.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/subdevice-model.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/subdevice-model.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/processing-block-model.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/processing-block-model.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/stream-model.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/stream-model.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/post-processing-filters.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/post-processing-filters.cpp"
|
||||
)
|
||||
|
||||
set(SW_UPDATE_FILES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/sw-update/http-downloader.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/sw-update/http-downloader.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/sw-update/dev-updates-profile.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/sw-update/dev-updates-profile.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/sw-update/versions-db-manager.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/sw-update/versions-db-manager.cpp"
|
||||
)
|
||||
|
||||
set(REFLECTIVITY_FILES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/reflectivity/reflectivity.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/reflectivity/reflectivity.cpp"
|
||||
)
|
||||
|
||||
set(UTILITIES_FILES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/utilities/imgui/wrap.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/utilities/imgui/wrap.cpp"
|
||||
)
|
||||
|
||||
set(COMMON_SRC
|
||||
${COMMON_SRC}
|
||||
${SW_UPDATE_FILES}
|
||||
${REFLECTIVITY_FILES}
|
||||
${UTILITIES_FILES}
|
||||
)
|
||||
|
@ -0,0 +1,66 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
#include <ios>
|
||||
#include <android/ndk-version.h>
|
||||
|
||||
#if __NDK_MAJOR__ <= 16
|
||||
namespace std
|
||||
{
|
||||
template <typename T>
|
||||
inline std::string to_string(T value)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << value;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T stoT(const std::string& value)
|
||||
{
|
||||
char* endptr;
|
||||
auto x = strtoimax(value.c_str(), &endptr, 10);
|
||||
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
inline long long stoll(const std::string& value)
|
||||
{
|
||||
return stoT<long long>(value);
|
||||
}
|
||||
|
||||
inline unsigned long stoul(const std::string& value)
|
||||
{
|
||||
return stoT<unsigned long>(value);
|
||||
}
|
||||
|
||||
inline int stoi(const std::string& value)
|
||||
{
|
||||
return stoT<int>(value);
|
||||
}
|
||||
|
||||
inline float stof(const std::string& value)
|
||||
{
|
||||
char* pEnd;
|
||||
return strtof(value.c_str(), &pEnd);
|
||||
}
|
||||
|
||||
inline double stod(const std::string& value)
|
||||
{
|
||||
char* pEnd;
|
||||
return strtod(value.c_str(), &pEnd);
|
||||
}
|
||||
|
||||
inline std::ios_base& hexfloat(std::ios_base& str)
|
||||
{
|
||||
str.setf(std::ios_base::fixed | std::ios_base::scientific, std::ios_base::floatfield);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
#endif // ANDROID_NDK_MAJOR
|
||||
|
@ -0,0 +1,74 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2021 Intel Corporation. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
|
||||
namespace rs2 {
|
||||
|
||||
|
||||
|
||||
inline float clamp( float x, float min, float max )
|
||||
{
|
||||
return std::max( std::min( max, x ), min );
|
||||
}
|
||||
|
||||
inline float smoothstep( float x, float min, float max )
|
||||
{
|
||||
if( max == min )
|
||||
{
|
||||
x = clamp( ( x - min ), 0.0, 1.0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
x = clamp( ( x - min ) / ( max - min ), 0.0, 1.0 );
|
||||
}
|
||||
|
||||
return x * x * ( 3 - 2 * x );
|
||||
}
|
||||
|
||||
|
||||
// Helper class that lets smoothly animate between its values
|
||||
template < class T > class animated
|
||||
{
|
||||
private:
|
||||
T _old, _new;
|
||||
std::chrono::system_clock::time_point _last_update;
|
||||
std::chrono::system_clock::duration _duration;
|
||||
|
||||
public:
|
||||
animated( T def, std::chrono::system_clock::duration duration = std::chrono::milliseconds( 200 ) )
|
||||
: _duration( duration )
|
||||
, _old( def )
|
||||
, _new( def )
|
||||
{
|
||||
static_assert( ( std::is_arithmetic< T >::value ), "animated class supports arithmetic built-in types only" );
|
||||
_last_update = std::chrono::system_clock::now();
|
||||
}
|
||||
animated & operator=( const T & other )
|
||||
{
|
||||
if( other != _new )
|
||||
{
|
||||
_old = get();
|
||||
_new = other;
|
||||
_last_update = std::chrono::system_clock::now();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
T get() const
|
||||
{
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto ms = std::chrono::duration_cast< std::chrono::microseconds >( now - _last_update ).count();
|
||||
auto duration_ms = std::chrono::duration_cast< std::chrono::microseconds >( _duration ).count();
|
||||
auto t = (float)ms / duration_ms;
|
||||
t = clamp( smoothstep( t, 0.f, 1.f ), 0.f, 1.f );
|
||||
return static_cast< T >( _old * ( 1.f - t ) + _new * t );
|
||||
}
|
||||
operator T() const { return get(); }
|
||||
T value() const { return _new; }
|
||||
};
|
||||
|
||||
|
||||
} // namespace rs2
|
@ -0,0 +1,451 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2023 Intel Corporation. All Rights Reserved.
|
||||
|
||||
#include <rs-config.h>
|
||||
#include "calibration-model.h"
|
||||
#include "device-model.h"
|
||||
#include "os.h"
|
||||
#include "ux-window.h"
|
||||
|
||||
#include "../src/ds/d400/d400-private.h"
|
||||
|
||||
|
||||
using namespace rs2;
|
||||
|
||||
calibration_model::calibration_model(rs2::device dev, std::shared_ptr<notifications_model> not_model)
|
||||
: dev(dev), _not_model(not_model)
|
||||
{
|
||||
_accept = config_file::instance().get_or_default(configurations::calibration::enable_writing, false);
|
||||
}
|
||||
|
||||
bool calibration_model::supports()
|
||||
{
|
||||
bool is_d400 = dev.supports(RS2_CAMERA_INFO_PRODUCT_LINE) ?
|
||||
std::string(dev.get_info(RS2_CAMERA_INFO_PRODUCT_LINE)) == "D400" : false;
|
||||
|
||||
return dev.is<rs2::auto_calibrated_device>() && is_d400;
|
||||
}
|
||||
|
||||
void calibration_model::draw_float(std::string name, float& x, const float& orig, bool& changed)
|
||||
{
|
||||
if( std::abs( x - orig ) > 0.00001 )
|
||||
ImGui::PushStyleColor( ImGuiCol_FrameBg, regular_blue );
|
||||
else ImGui::PushStyleColor(ImGuiCol_FrameBg, black);
|
||||
if (ImGui::DragFloat(std::string( rsutils::string::from() << "##" << name).c_str(), &x, 0.001f))
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
void calibration_model::draw_float4x4(std::string name, float3x3& feild,
|
||||
const float3x3& original, bool& changed)
|
||||
{
|
||||
ImGui::SetCursorPosX(10);
|
||||
ImGui::Text("%s:", name.c_str()); ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(200);
|
||||
|
||||
ImGui::PushItemWidth(120);
|
||||
ImGui::SetCursorPosX(200);
|
||||
draw_float(name + "_XX", feild.x.x, original.x.x, changed);
|
||||
ImGui::SameLine();
|
||||
draw_float(name + "_XY", feild.x.y, original.x.y, changed);
|
||||
ImGui::SameLine();
|
||||
draw_float(name + "_XZ", feild.x.z, original.x.z, changed);
|
||||
|
||||
ImGui::SetCursorPosX(200);
|
||||
draw_float(name + "_YX", feild.y.x, original.y.x, changed);
|
||||
ImGui::SameLine();
|
||||
draw_float(name + "_YY", feild.y.y, original.y.y, changed);
|
||||
ImGui::SameLine();
|
||||
draw_float(name + "_YZ", feild.y.z, original.y.z, changed);
|
||||
|
||||
ImGui::SetCursorPosX(200);
|
||||
draw_float(name + "_ZX", feild.z.x, original.z.x, changed);
|
||||
ImGui::SameLine();
|
||||
draw_float(name + "_ZY", feild.z.y, original.z.y, changed);
|
||||
ImGui::SameLine();
|
||||
draw_float(name + "_ZZ", feild.z.z, original.z.z, changed);
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
|
||||
}
|
||||
|
||||
void calibration_model::update(ux_window& window, std::string& error_message)
|
||||
{
|
||||
const auto window_name = "Calibration Window";
|
||||
|
||||
if (to_open)
|
||||
{
|
||||
try
|
||||
{
|
||||
_calibration = dev.as<rs2::auto_calibrated_device>().get_calibration_table();
|
||||
_original = _calibration;
|
||||
ImGui::OpenPopup(window_name);
|
||||
}
|
||||
catch(std::exception e)
|
||||
{
|
||||
error_message = e.what();
|
||||
}
|
||||
to_open = false;
|
||||
}
|
||||
|
||||
auto table = (librealsense::ds::d400_coefficients_table*)_calibration.data();
|
||||
auto orig_table = (librealsense::ds::d400_coefficients_table*)_original.data();
|
||||
bool changed = false;
|
||||
|
||||
const float w = 620;
|
||||
const float h = 500;
|
||||
const float x0 = std::max(window.width() - w, 0.f) / 2;
|
||||
const float y0 = std::max(window.height() - h, 0.f) / 2;
|
||||
ImGui::SetNextWindowPos({ x0, y0 });
|
||||
ImGui::SetNextWindowSize({ w, h });
|
||||
|
||||
auto flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_PopupBg, sensor_bg);
|
||||
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, white);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, light_grey);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(5, 5));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 1);
|
||||
|
||||
if (ImGui::BeginPopupModal(window_name, nullptr, flags))
|
||||
{
|
||||
if (error_message != "") ImGui::CloseCurrentPopup();
|
||||
|
||||
std::string title_message = "CAMERA CALIBRATION";
|
||||
auto title_size = ImGui::CalcTextSize(title_message.c_str());
|
||||
ImGui::SetCursorPosX(w / 2 - title_size.x / 2);
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
|
||||
ImGui::PushFont(window.get_large_font());
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, white);
|
||||
ImGui::Text("%s", title_message.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopFont();
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
|
||||
|
||||
ImGui::SetCursorPosX(w / 2 - 260 / 2);
|
||||
if (ImGui::Button(u8"\uF07C Load...", ImVec2(70, 30)))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (auto fn = file_dialog_open(file_dialog_mode::open_file, "Calibration JSON\0*.json\0", nullptr, nullptr))
|
||||
{
|
||||
config_file cf(fn);
|
||||
table->baseline = cf.get("baseline");
|
||||
|
||||
auto load_float3x4 = [&](std::string name, librealsense::float3x3& m){
|
||||
m.x.x = cf.get(std::string( rsutils::string::from() << name << ".x.x").c_str());
|
||||
m.x.y = cf.get(std::string( rsutils::string::from() << name << ".x.y").c_str());
|
||||
m.x.z = cf.get(std::string( rsutils::string::from() << name << ".x.z").c_str());
|
||||
|
||||
m.y.x = cf.get(std::string( rsutils::string::from() << name << ".y.x").c_str());
|
||||
m.y.y = cf.get(std::string( rsutils::string::from() << name << ".y.y").c_str());
|
||||
m.y.z = cf.get(std::string( rsutils::string::from() << name << ".y.z").c_str());
|
||||
|
||||
m.z.x = cf.get(std::string( rsutils::string::from() << name << ".z.x").c_str());
|
||||
m.z.y = cf.get(std::string( rsutils::string::from() << name << ".z.y").c_str());
|
||||
m.z.z = cf.get(std::string( rsutils::string::from() << name << ".z.z").c_str());
|
||||
};
|
||||
|
||||
load_float3x4("intrinsic_left", table->intrinsic_left);
|
||||
load_float3x4("intrinsic_right", table->intrinsic_right);
|
||||
load_float3x4("world2left_rot", table->world2left_rot);
|
||||
load_float3x4("world2right_rot", table->world2right_rot);
|
||||
|
||||
for (int i = 0; i < librealsense::ds::max_ds_rect_resolutions; i++)
|
||||
{
|
||||
table->rect_params[i].x = cf.get(std::string( rsutils::string::from() << "rectified." << i << ".fx").c_str());
|
||||
table->rect_params[i].y = cf.get(std::string( rsutils::string::from() << "rectified." << i << ".fy").c_str());
|
||||
|
||||
table->rect_params[i].z = cf.get(std::string( rsutils::string::from() << "rectified." << i << ".ppx").c_str());
|
||||
table->rect_params[i].w = cf.get(std::string( rsutils::string::from() << "rectified." << i << ".ppy").c_str());
|
||||
}
|
||||
}
|
||||
|
||||
changed = true;
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
error_message = ex.what();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
window.link_hovered();
|
||||
ImGui::SetTooltip("%s", "Load calibration from file");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(u8"\uF0C7 Save As...", ImVec2(100, 30)))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (auto fn = file_dialog_open(file_dialog_mode::save_file, "Calibration JSON\0*.json\0", nullptr, nullptr))
|
||||
{
|
||||
config_file cf(fn);
|
||||
cf.set("baseline", table->baseline);
|
||||
|
||||
auto save_float3x4 = [&](std::string name, librealsense::float3x3& m){
|
||||
cf.set(std::string( rsutils::string::from() << name << ".x.x").c_str(), m.x.x);
|
||||
cf.set(std::string( rsutils::string::from() << name << ".x.y").c_str(), m.x.y);
|
||||
cf.set(std::string( rsutils::string::from() << name << ".x.z").c_str(), m.x.z);
|
||||
|
||||
cf.set(std::string( rsutils::string::from() << name << ".y.x").c_str(), m.y.x);
|
||||
cf.set(std::string( rsutils::string::from() << name << ".y.y").c_str(), m.y.y);
|
||||
cf.set(std::string( rsutils::string::from() << name << ".y.z").c_str(), m.y.z);
|
||||
|
||||
cf.set(std::string( rsutils::string::from() << name << ".z.x").c_str(), m.z.x);
|
||||
cf.set(std::string( rsutils::string::from() << name << ".z.y").c_str(), m.z.y);
|
||||
cf.set(std::string( rsutils::string::from() << name << ".z.z").c_str(), m.z.z);
|
||||
};
|
||||
|
||||
save_float3x4("intrinsic_left", table->intrinsic_left);
|
||||
save_float3x4("intrinsic_right", table->intrinsic_right);
|
||||
save_float3x4("world2left_rot", table->world2left_rot);
|
||||
save_float3x4("world2right_rot", table->world2right_rot);
|
||||
|
||||
for (int i = 0; i < librealsense::ds::max_ds_rect_resolutions; i++)
|
||||
{
|
||||
auto xy = librealsense::ds::resolutions_list[(librealsense::ds::ds_rect_resolutions)i];
|
||||
int w = xy.x; int h = xy.y;
|
||||
|
||||
cf.set(std::string( rsutils::string::from() << "rectified." << i << ".width").c_str(), w);
|
||||
cf.set(std::string( rsutils::string::from() << "rectified." << i << ".height").c_str(), h);
|
||||
|
||||
cf.set(std::string( rsutils::string::from() << "rectified." << i << ".fx").c_str(), table->rect_params[i].x);
|
||||
cf.set(std::string( rsutils::string::from() << "rectified." << i << ".fy").c_str(), table->rect_params[i].y);
|
||||
|
||||
cf.set(std::string( rsutils::string::from() << "rectified." << i << ".ppx").c_str(), table->rect_params[i].z);
|
||||
cf.set(std::string( rsutils::string::from() << "rectified." << i << ".ppy").c_str(), table->rect_params[i].w);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
error_message = ex.what();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
window.link_hovered();
|
||||
ImGui::SetTooltip("%s", "Save calibration image to file");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (_accept)
|
||||
{
|
||||
if (ImGui::Button(u8"\uF275 Restore Factory", ImVec2(115, 30)))
|
||||
{
|
||||
try
|
||||
{
|
||||
dev.as<rs2::auto_calibrated_device>().reset_to_factory_calibration();
|
||||
_calibration = dev.as<rs2::auto_calibrated_device>().get_calibration_table();
|
||||
_original = _calibration;
|
||||
table = reinterpret_cast< librealsense::ds::d400_coefficients_table * >( _calibration.data() );
|
||||
orig_table = reinterpret_cast< librealsense::ds::d400_coefficients_table * >( _original.data() );
|
||||
changed = true;
|
||||
|
||||
if (auto nm = _not_model.lock())
|
||||
{
|
||||
nm->add_notification({ rsutils::string::from() << "Depth Calibration is reset to Factory Settings",
|
||||
RS2_LOG_SEVERITY_INFO, RS2_NOTIFICATION_CATEGORY_HARDWARE_EVENT });
|
||||
}
|
||||
}
|
||||
catch(const std::exception& ex)
|
||||
{
|
||||
error_message = ex.what();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
window.link_hovered();
|
||||
ImGui::SetTooltip("%s", "Restore calibration in flash to factory settings");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, grey);
|
||||
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, grey);
|
||||
|
||||
ImGui::Button(u8"\uF275 Restore Factory", ImVec2(115, 30));
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("%s", "Write selected calibration table to the device. For advanced users");
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(2);
|
||||
}
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, dark_sensor_bg);
|
||||
|
||||
ImGui::BeginChild("##CalibData",ImVec2(w - 15, h - 110), true);
|
||||
|
||||
ImGui::SetCursorPosX(10);
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
|
||||
|
||||
ImGui::Text("Stereo Baseline(mm):"); ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(200);
|
||||
|
||||
ImGui::PushItemWidth(120);
|
||||
draw_float("Baseline", table->baseline, orig_table->baseline, changed);
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
draw_float4x4("Left Intrinsics", table->intrinsic_left, orig_table->intrinsic_left, changed);
|
||||
draw_float4x4("Right Intrinsics", table->intrinsic_right, orig_table->intrinsic_right, changed);
|
||||
draw_float4x4("World to Left Rotation", table->world2left_rot, orig_table->world2left_rot, changed);
|
||||
draw_float4x4("World to Right Rotation", table->world2right_rot, orig_table->world2right_rot, changed);
|
||||
|
||||
ImGui::SetCursorPosX(10);
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
|
||||
|
||||
ImGui::Text("Rectified Resolution:"); ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(200);
|
||||
|
||||
std::vector<std::string> resolution_names;
|
||||
std::vector<const char*> resolution_names_char;
|
||||
std::vector<int> resolution_offset;
|
||||
for (int i = 0; i < librealsense::ds::max_ds_rect_resolutions; i++)
|
||||
{
|
||||
auto xy = librealsense::ds::resolutions_list[(librealsense::ds::ds_rect_resolutions)i];
|
||||
int w = xy.x; int h = xy.y;
|
||||
if (w != 0) {
|
||||
resolution_offset.push_back(i);
|
||||
std::string name = rsutils::string::from() << w << " x " << h;
|
||||
resolution_names.push_back(name);
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < resolution_offset.size(); i++)
|
||||
{
|
||||
resolution_names_char.push_back(resolution_names[i].c_str());
|
||||
}
|
||||
|
||||
ImGui::PushItemWidth(120);
|
||||
ImGui::Combo("##RectifiedResolutions", &selected_resolution, resolution_names_char.data(), int(resolution_names_char.size()));
|
||||
|
||||
ImGui::SetCursorPosX(10);
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
|
||||
|
||||
ImGui::Text("Focal Length:"); ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(200);
|
||||
|
||||
draw_float("FocalX", table->rect_params[selected_resolution].x, orig_table->rect_params[selected_resolution].x, changed);
|
||||
ImGui::SameLine();
|
||||
draw_float("FocalY", table->rect_params[selected_resolution].y, orig_table->rect_params[selected_resolution].y, changed);
|
||||
|
||||
ImGui::SetCursorPosX(10);
|
||||
ImGui::Text("Principal Point:"); ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(200);
|
||||
|
||||
draw_float("PPX", table->rect_params[selected_resolution].z, orig_table->rect_params[selected_resolution].z, changed);
|
||||
ImGui::SameLine();
|
||||
draw_float("PPY", table->rect_params[selected_resolution].w, orig_table->rect_params[selected_resolution].w, changed);
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
if (ImGui::IsWindowHovered()) window.set_hovered_over_input();
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::SetCursorScreenPos({ (float)(x0 + 10), (float)(y0 + h - 30) });
|
||||
if (ImGui::Checkbox("I know what I'm doing", &_accept))
|
||||
{
|
||||
config_file::instance().set(configurations::calibration::enable_writing, _accept);
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("%s", "Changing calibration will affect depth quality. Changes are persistent.\nThere is an option to get back to factory calibration, but it maybe worse than current calibration\nBefore writing to flash, we strongly recommend to make a file backup");
|
||||
}
|
||||
|
||||
ImGui::SetCursorScreenPos({ (float)(x0 + w - 230), (float)(y0 + h - 30) });
|
||||
|
||||
if (ImGui::Button("Cancel", ImVec2(100, 25)))
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
window.link_hovered();
|
||||
ImGui::SetTooltip("%s", "Close without saving any changes");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
auto streams = dev.query_sensors()[0].get_active_streams();
|
||||
if (_accept && streams.size())
|
||||
{
|
||||
if (ImGui::Button(u8"\uF2DB Write Table", ImVec2(120, 25)))
|
||||
{
|
||||
try
|
||||
{
|
||||
auto actual_data = _calibration.data() + sizeof(librealsense::ds::table_header);
|
||||
auto actual_data_size = _calibration.size() - sizeof(librealsense::ds::table_header);
|
||||
auto crc = rsutils::number::calc_crc32( actual_data, actual_data_size );
|
||||
table->header.crc32 = crc;
|
||||
dev.as<rs2::auto_calibrated_device>().set_calibration_table(_calibration);
|
||||
dev.as<rs2::auto_calibrated_device>().write_calibration();
|
||||
_original = _calibration;
|
||||
orig_table = reinterpret_cast< librealsense::ds::d400_coefficients_table * >( _original.data() );
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
error_message = ex.what();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
window.link_hovered();
|
||||
ImGui::SetTooltip("%s", "Write selected calibration table to the device");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, grey);
|
||||
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, grey);
|
||||
|
||||
ImGui::Button(u8"\uF2DB Write Table", ImVec2(120, 25));
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("%s", "Write selected calibration table to the device. For advanced users");
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(2);
|
||||
}
|
||||
|
||||
if (changed && streams.size())
|
||||
{
|
||||
try
|
||||
{
|
||||
dev.as<rs2::auto_calibrated_device>().set_calibration_table(_calibration);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
try
|
||||
{
|
||||
dev.query_sensors()[0].close();
|
||||
dev.query_sensors()[0].open(streams);
|
||||
dev.as<rs2::auto_calibrated_device>().set_calibration_table(_calibration);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
error_message = ex.what();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::IsWindowHovered()) window.set_hovered_over_input();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
ImGui::PopStyleColor(3);
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2024 Intel Corporation. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include <librealsense2/rs.hpp>
|
||||
#include "notifications.h"
|
||||
#include <rsutils/number/float3.h>
|
||||
|
||||
|
||||
namespace rs2
|
||||
{
|
||||
class ux_window;
|
||||
|
||||
class calibration_model
|
||||
{
|
||||
using float3x3 = rsutils::number::float3x3;
|
||||
|
||||
public:
|
||||
calibration_model(rs2::device dev, std::shared_ptr<notifications_model> not_model);
|
||||
|
||||
bool supports();
|
||||
|
||||
void update(ux_window& window, std::string& error_message);
|
||||
|
||||
void open() { to_open = true; }
|
||||
|
||||
private:
|
||||
void draw_float4x4(std::string name, float3x3 & feild, const float3x3& original, bool& changed);
|
||||
void draw_float(std::string name, float& x, const float& orig, bool& changed);
|
||||
|
||||
rs2::device dev;
|
||||
bool to_open = false;
|
||||
bool _accept = false;
|
||||
|
||||
std::vector<uint8_t> _calibration;
|
||||
std::vector<uint8_t> _original;
|
||||
|
||||
int selected_resolution = 0;
|
||||
|
||||
std::weak_ptr<notifications_model> _not_model;
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,466 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2023 Intel Corporation. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include "notifications.h"
|
||||
#include "realsense-ui-advanced-mode.h"
|
||||
#include <rsutils/json.h>
|
||||
#include "sw-update/dev-updates-profile.h"
|
||||
#include <rsutils/time/periodic-timer.h>
|
||||
#include "updates-model.h"
|
||||
#include "calibration-model.h"
|
||||
#include "objects-in-frame.h"
|
||||
|
||||
ImVec4 from_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a, bool consistent_color = false);
|
||||
ImVec4 operator+(const ImVec4& c, float v);
|
||||
|
||||
static const ImVec4 light_blue = from_rgba(0, 174, 239, 255, true); // Light blue color for selected elements such as play button glyph when paused
|
||||
static const ImVec4 regular_blue = from_rgba(0, 115, 200, 255, true); // Checkbox mark, slider grabber
|
||||
static const ImVec4 light_grey = from_rgba(0xc3, 0xd5, 0xe5, 0xff, true); // Text
|
||||
static const ImVec4 dark_window_background = from_rgba(9, 11, 13, 255);
|
||||
static const ImVec4 almost_white_bg = from_rgba(230, 230, 230, 255, true);
|
||||
static const ImVec4 black = from_rgba(0, 0, 0, 255, true);
|
||||
static const ImVec4 transparent = from_rgba(0, 0, 0, 0, true);
|
||||
static const ImVec4 white = from_rgba(0xff, 0xff, 0xff, 0xff, true);
|
||||
static const ImVec4 scrollbar_bg = from_rgba(14, 17, 20, 255);
|
||||
static const ImVec4 scrollbar_grab = from_rgba(54, 66, 67, 255);
|
||||
static const ImVec4 grey{ 0.5f,0.5f,0.5f,1.f };
|
||||
static const ImVec4 dark_grey = from_rgba(30, 30, 30, 255);
|
||||
static const ImVec4 sensor_header_light_blue = from_rgba(80, 99, 115, 0xff);
|
||||
static const ImVec4 sensor_bg = from_rgba(36, 44, 51, 0xff);
|
||||
static const ImVec4 redish = from_rgba(255, 46, 54, 255, true);
|
||||
static const ImVec4 light_red = from_rgba(255, 146, 154, 255, true);
|
||||
static const ImVec4 dark_red = from_rgba(200, 46, 54, 255, true);
|
||||
static const ImVec4 button_color = from_rgba(62, 77, 89, 0xff);
|
||||
static const ImVec4 header_window_bg = from_rgba(36, 44, 54, 0xff);
|
||||
static const ImVec4 header_color = from_rgba(62, 77, 89, 255);
|
||||
static const ImVec4 title_color = from_rgba(27, 33, 38, 255);
|
||||
static const ImVec4 device_info_color = from_rgba(33, 40, 46, 255);
|
||||
static const ImVec4 yellow = from_rgba(229, 195, 101, 255, true);
|
||||
static const ImVec4 yellowish = from_rgba(255, 253, 191, 255, true);
|
||||
static const ImVec4 green = from_rgba(0x20, 0xe0, 0x20, 0xff, true);
|
||||
static const ImVec4 dark_sensor_bg = from_rgba(0x1b, 0x21, 0x25, 170);
|
||||
static const ImVec4 red = from_rgba(233, 0, 0, 255, true);
|
||||
static const ImVec4 greenish = from_rgba(67, 163, 97, 255);
|
||||
static const ImVec4 orange = from_rgba(255, 157, 0, 255, true);
|
||||
|
||||
inline ImVec4 operator*(const ImVec4& color, float t)
|
||||
{
|
||||
return ImVec4(color.x * t, color.y * t, color.z * t, color.w * t);
|
||||
}
|
||||
inline ImVec4 operator+(const ImVec4& a, const ImVec4& b)
|
||||
{
|
||||
return ImVec4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
|
||||
}
|
||||
|
||||
inline ImVec4 blend(const ImVec4& c, float a)
|
||||
{
|
||||
return{ c.x, c.y, c.z, a * c.w };
|
||||
}
|
||||
|
||||
namespace rs2
|
||||
{
|
||||
void imgui_easy_theming(ImFont*& font_dynamic, ImFont*& font_18, ImFont*& monofont, int& font_size);
|
||||
|
||||
constexpr const char* server_versions_db_url = "https://librealsense.intel.com/Releases/rs_versions_db.json";
|
||||
|
||||
typedef std::vector<std::unique_ptr<device_model>> device_models_list;
|
||||
|
||||
void open_issue(const device_models_list& devices);
|
||||
|
||||
struct textual_icon
|
||||
{
|
||||
explicit constexpr textual_icon(const char(&unicode_icon)[4]) :
|
||||
_icon{ unicode_icon[0], unicode_icon[1], unicode_icon[2], unicode_icon[3] }
|
||||
{
|
||||
}
|
||||
operator const char* () const
|
||||
{
|
||||
return _icon.data();
|
||||
}
|
||||
private:
|
||||
std::array<char, 5> _icon;
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const textual_icon& i)
|
||||
{
|
||||
return os << static_cast<const char*>(i);
|
||||
}
|
||||
|
||||
namespace configurations
|
||||
{
|
||||
namespace record
|
||||
{
|
||||
static const char* file_save_mode{ "record.file_save_mode" };
|
||||
static const char* default_path{ "record.default_path" };
|
||||
static const char* compression_mode{ "record.compression" };
|
||||
}
|
||||
namespace update
|
||||
{
|
||||
static const char* allow_rc_firmware{ "update.allow_rc_firmware" };
|
||||
static const char* recommend_updates{ "update.recommend_updates" };
|
||||
static const char* recommend_calibration{ "update.recommend_calibration" };
|
||||
static const char* sw_updates_url{ "update.sw_update_url" };
|
||||
static const char* sw_updates_official_server{ "update.sw_update_official_server" };
|
||||
}
|
||||
namespace calibration
|
||||
{
|
||||
static const char* enable_writing{ "calibration.enable_writing" };
|
||||
}
|
||||
namespace viewer
|
||||
{
|
||||
static const char* is_3d_view{ "viewer_model.is_3d_view" };
|
||||
static const char* ground_truth_r{ "viewer_model.ground_truth_r" };
|
||||
static const char* target_width_r{ "viewer_model.target_width_r" };
|
||||
static const char* target_height_r{ "viewer_model.target_height_r" };
|
||||
static const char* continue_with_ui_not_aligned{ "viewer_model.continue_with_ui_not_aligned" };
|
||||
static const char* continue_with_current_fw{ "viewer_model.continue_with_current_fw" };
|
||||
static const char* settings_tab{ "viewer_model.settings_tab" };
|
||||
static const char* sdk_version{ "viewer_model.sdk_version" };
|
||||
static const char* last_calib_notice{ "viewer_model.last_calib_notice" };
|
||||
static const char* is_measuring{ "viewer_model.is_measuring" };
|
||||
static const char* output_open{ "viewer_model.output_open" };
|
||||
static const char* dashboard_open{ "viewer_model.dashboard_open" };
|
||||
static const char* search_term{ "viewer_model.search_term" };
|
||||
|
||||
static const char* log_to_console{ "viewer_model.log_to_console" };
|
||||
static const char* log_to_file{ "viewer_model.log_to_file" };
|
||||
static const char* log_filename{ "viewer_model.log_filename" };
|
||||
static const char* log_severity{ "viewer_model.log_severity" };
|
||||
static const char* post_processing{ "viewer_model.post_processing" };
|
||||
static const char* show_map_ruler{ "viewer_model.show_map_ruler" };
|
||||
static const char* show_stream_details{ "viewer_model.show_stream_details" };
|
||||
static const char* metric_system{ "viewer_model.metric_system" };
|
||||
static const char* shading_mode{ "viewer_model.shading_mode" };
|
||||
static const char* commands_xml{ "viewer_model.commands_xml" };
|
||||
static const char* hwlogger_xml{ "viewer_model.hwlogger_xml" };
|
||||
|
||||
static const char* last_ip{ "viewer_model.last_ip" };
|
||||
}
|
||||
namespace window
|
||||
{
|
||||
static const char* is_fullscreen{ "window.is_fullscreen" };
|
||||
static const char* saved_pos{ "window.saved_pos" };
|
||||
static const char* position_x{ "window.position_x" };
|
||||
static const char* position_y{ "window.position_y" };
|
||||
static const char* saved_size{ "window.saved_size" };
|
||||
static const char* width{ "window.width" };
|
||||
static const char* height{ "window.height" };
|
||||
static const char* maximized{ "window.maximized" };
|
||||
static const char* font_size{ "window.font_size" };
|
||||
}
|
||||
namespace performance
|
||||
{
|
||||
static const char* glsl_for_rendering{ "performance.glsl_for_rendering.v2" };
|
||||
static const char* glsl_for_processing{ "performance.glsl_for_processing.v2" };
|
||||
static const char* enable_msaa{ "performance.msaa" };
|
||||
static const char* msaa_samples{ "performance.msaa_samples" };
|
||||
static const char* show_fps{ "performance.show_fps" };
|
||||
static const char* vsync{ "performance.vsync" };
|
||||
static const char* font_oversample{ "performance.font_oversample.v2" };
|
||||
static const char* show_skybox{ "performance.show_skybox" };
|
||||
static const char* occlusion_invalidation{ "performance.occlusion_invalidation" };
|
||||
}
|
||||
namespace ply
|
||||
{
|
||||
static const char* mesh{ "ply.mesh" };
|
||||
static const char* use_normals{ "ply.normals" };
|
||||
static const char* encoding{ "ply.encoding" };
|
||||
|
||||
enum encoding_types
|
||||
{
|
||||
textual = 0,
|
||||
binary = 1
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace textual_icons
|
||||
{
|
||||
// A note to a maintainer - preserve order when adding values to avoid duplicates
|
||||
static const textual_icon file_movie{ u8"\uf008" };
|
||||
static const textual_icon times{ u8"\uf00d" };
|
||||
static const textual_icon download{ u8"\uf019" };
|
||||
static const textual_icon refresh{ u8"\uf021" };
|
||||
static const textual_icon lock{ u8"\uf023" };
|
||||
static const textual_icon camera{ u8"\uf030" };
|
||||
static const textual_icon video_camera{ u8"\uf03d" };
|
||||
static const textual_icon edit{ u8"\uf044" };
|
||||
static const textual_icon step_backward{ u8"\uf048" };
|
||||
static const textual_icon play{ u8"\uf04b" };
|
||||
static const textual_icon pause{ u8"\uf04c" };
|
||||
static const textual_icon stop{ u8"\uf04d" };
|
||||
static const textual_icon step_forward{ u8"\uf051" };
|
||||
static const textual_icon plus_circle{ u8"\uf055" };
|
||||
static const textual_icon question_mark{ u8"\uf059" };
|
||||
static const textual_icon info_circle{ u8"\uf05a" };
|
||||
static const textual_icon fix_up{ u8"\uf062" };
|
||||
static const textual_icon minus{ u8"\uf068" };
|
||||
static const textual_icon exclamation_triangle{ u8"\uf071" };
|
||||
static const textual_icon shopping_cart{ u8"\uf07a" };
|
||||
static const textual_icon bar_chart{ u8"\uf080" };
|
||||
static const textual_icon upload{ u8"\uf093" };
|
||||
static const textual_icon square_o{ u8"\uf096" };
|
||||
static const textual_icon unlock{ u8"\uf09c" };
|
||||
static const textual_icon floppy{ u8"\uf0c7" };
|
||||
static const textual_icon square{ u8"\uf0c8" };
|
||||
static const textual_icon bars{ u8"\uf0c9" };
|
||||
static const textual_icon caret_down{ u8"\uf0d7" };
|
||||
static const textual_icon repeat{ u8"\uf0e2" };
|
||||
static const textual_icon circle{ u8"\uf111" };
|
||||
static const textual_icon check_square_o{ u8"\uf14a" };
|
||||
static const textual_icon cubes{ u8"\uf1b3" };
|
||||
static const textual_icon toggle_off{ u8"\uf204" };
|
||||
static const textual_icon toggle_on{ u8"\uf205" };
|
||||
static const textual_icon connectdevelop{ u8"\uf20e" };
|
||||
static const textual_icon usb_type{ u8"\uf287" };
|
||||
static const textual_icon braille{ u8"\uf2a1" };
|
||||
static const textual_icon window_maximize{ u8"\uf2d0" };
|
||||
static const textual_icon window_restore{ u8"\uf2d2" };
|
||||
static const textual_icon grid{ u8"\uf1cb" };
|
||||
static const textual_icon exit{ u8"\uf011" };
|
||||
static const textual_icon see_less{ u8"\uf070" };
|
||||
static const textual_icon dotdotdot{ u8"\uf141" };
|
||||
static const textual_icon link{ u8"\uf08e" };
|
||||
static const textual_icon throphy{ u8"\uF091" };
|
||||
static const textual_icon metadata{ u8"\uF0AE" };
|
||||
static const textual_icon check{ u8"\uF00C" };
|
||||
static const textual_icon mail{ u8"\uF01C" };
|
||||
static const textual_icon cube{ u8"\uf1b2" };
|
||||
static const textual_icon measure{ u8"\uf545" };
|
||||
static const textual_icon wifi{ u8"\uf1eb" };
|
||||
}
|
||||
|
||||
class viewer_model;
|
||||
class ux_window;
|
||||
class subdevice_model;
|
||||
|
||||
class syncer_model
|
||||
{
|
||||
public:
|
||||
syncer_model() :
|
||||
_active(true) {}
|
||||
|
||||
std::shared_ptr<rs2::asynchronous_syncer> create_syncer()
|
||||
{
|
||||
stop();
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
auto shared_syncer = std::make_shared<rs2::asynchronous_syncer>();
|
||||
|
||||
// This queue stores the output from the syncer, and has to be large enough to deal with
|
||||
// slowdowns on the processing/rendering threads of the Viewer to avoid frame drops. Frame
|
||||
// drops can be pretty noticeable to the user!
|
||||
//
|
||||
// The syncer may also give out frames in bursts. This commonly happens, for example, when
|
||||
// streams have different FPS, and is a known issue. Even with same-FPS streams, the actual
|
||||
// FPS may change depending on a number of variables (e.g., exposure). When FPS is not the
|
||||
// same between the streams, a latency is introduced and bursts from the syncer are the
|
||||
// result.
|
||||
//
|
||||
// Bursts are so fast the other threads will never have a chance to pull them in time. For
|
||||
// example, the syncer output can be the following, all one after the other:
|
||||
//
|
||||
// [Color: timestamp 100 (arrived @ 105), Infrared: timestamp 100 (arrived at 150)]
|
||||
// [Color: timestamp 116 (arrived @ 120)]
|
||||
// [Color: timestamp 132 (arrived @ 145)]
|
||||
//
|
||||
// They are received one at a time & pushed into the syncer, which will wait and keep all of
|
||||
// them inside until a match with Infrared is possible. Once that happens, it will output
|
||||
// everything it has as a burst.
|
||||
//
|
||||
// The queue size must therefore be big enough to deal with expected latency: the more
|
||||
// latency, the bigger the burst.
|
||||
//
|
||||
// Another option is to use an aggregator, similar to the behavior inside the pipeline.
|
||||
// But this still doesn't solve the issue of the bursts: we'll get frame drops in the fast
|
||||
// stream instead of the slow.
|
||||
//
|
||||
rs2::frame_queue q(10);
|
||||
|
||||
_syncers.push_back({ shared_syncer,q });
|
||||
shared_syncer->start([this, q](rs2::frame f)
|
||||
{
|
||||
q.enqueue(f);
|
||||
on_frame();
|
||||
});
|
||||
start();
|
||||
return shared_syncer;
|
||||
}
|
||||
|
||||
void remove_syncer(std::shared_ptr<rs2::asynchronous_syncer> s)
|
||||
{
|
||||
stop();
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
_syncers.erase(std::remove_if(_syncers.begin(), _syncers.end(),
|
||||
[s](std::pair<std::shared_ptr<rs2::asynchronous_syncer>, rs2::frame_queue> pair)
|
||||
{
|
||||
return pair.first.get() == s.get();
|
||||
}), _syncers.end());
|
||||
start();
|
||||
}
|
||||
|
||||
std::vector<rs2::frameset> try_wait_for_frames()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
std::vector<rs2::frameset> result;
|
||||
for (auto&& s = _syncers.begin(); s != _syncers.end() && _active; s++)
|
||||
{
|
||||
rs2::frameset f;
|
||||
if (s->second.try_wait_for_frame(&f, 1))
|
||||
{
|
||||
result.push_back(f);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
_active.exchange(false);
|
||||
}
|
||||
|
||||
void start()
|
||||
{
|
||||
_active.exchange(true);
|
||||
}
|
||||
|
||||
std::function<void()> on_frame = [] {};
|
||||
private:
|
||||
std::vector<std::pair<std::shared_ptr<rs2::asynchronous_syncer>, rs2::frame_queue>> _syncers;
|
||||
std::mutex _mutex;
|
||||
std::atomic<bool> _active;
|
||||
};
|
||||
|
||||
class device_model
|
||||
{
|
||||
public:
|
||||
typedef std::function<void(std::function<void()> load)> json_loading_func;
|
||||
|
||||
void reset();
|
||||
explicit device_model(device& dev, std::string& error_message, viewer_model& viewer, bool new_device_connected = true, bool allow_remove=true);
|
||||
~device_model();
|
||||
void start_recording(const std::string& path, std::string& error_message);
|
||||
void stop_recording(viewer_model& viewer);
|
||||
void pause_record();
|
||||
void resume_record();
|
||||
|
||||
void refresh_notifications(viewer_model& viewer);
|
||||
bool check_for_bundled_fw_update( const rs2::context & ctx,
|
||||
std::shared_ptr< notifications_model > not_model,
|
||||
bool reset_delay = false );
|
||||
|
||||
int draw_playback_panel(ux_window& window, ImFont* font, viewer_model& view);
|
||||
bool draw_advanced_controls(viewer_model& view, ux_window& window, std::string& error_message);
|
||||
void draw_controls(float panel_width, float panel_height,
|
||||
ux_window& window,
|
||||
std::string& error_message,
|
||||
device_model*& device_to_remove,
|
||||
viewer_model& viewer, float windows_width,
|
||||
std::vector<std::function<void()>>& draw_later,
|
||||
bool load_json_if_streaming = false,
|
||||
json_loading_func json_loading = [](std::function<void()> load) {load(); },
|
||||
bool draw_device_outline = true);
|
||||
void handle_hardware_events(const std::string& serialized_data);
|
||||
void begin_update(std::vector<uint8_t> data,
|
||||
viewer_model& viewer, std::string& error_message);
|
||||
void begin_update_unsigned(viewer_model& viewer, std::string& error_message);
|
||||
void check_for_device_updates(viewer_model& viewer, bool activated_by_user = false);
|
||||
bool disable_record_button_logic(bool is_streaming, bool is_playback_device);
|
||||
std::string get_record_button_hover_text(bool is_streaming);
|
||||
|
||||
|
||||
std::shared_ptr< atomic_objects_in_frame > get_detected_objects() const { return _detected_objects; }
|
||||
|
||||
std::vector<std::shared_ptr<subdevice_model>> subdevices;
|
||||
std::shared_ptr<syncer_model> syncer;
|
||||
std::shared_ptr<rs2::asynchronous_syncer> dev_syncer;
|
||||
bool is_streaming() const;
|
||||
bool metadata_supported = false;
|
||||
bool get_curr_advanced_controls = true;
|
||||
device dev;
|
||||
std::string id;
|
||||
bool is_recording = false;
|
||||
int seek_pos = 0;
|
||||
int playback_speed_index = 2;
|
||||
bool _playback_repeat = true;
|
||||
bool _should_replay = false;
|
||||
bool show_device_info = false;
|
||||
bool _allow_remove = true;
|
||||
bool show_depth_only = false;
|
||||
bool show_stream_selection = true;
|
||||
std::vector<std::pair<std::string, std::string>> infos;
|
||||
std::vector<std::string> restarting_device_info;
|
||||
std::set<std::string> advanced_mode_settings_file_names;
|
||||
std::string selected_file_preset;
|
||||
|
||||
std::vector<std::shared_ptr<notification_model>> related_notifications;
|
||||
|
||||
private:
|
||||
// This class is in charge of camera accuracy health window parameters,
|
||||
// Needed as a member for reseting the window memory on device disconnection.
|
||||
|
||||
|
||||
void draw_info_icon(ux_window& window, ImFont* font, const ImVec2& size);
|
||||
int draw_seek_bar();
|
||||
int draw_playback_controls(ux_window& window, ImFont* font, viewer_model& view);
|
||||
advanced_mode_control amc;
|
||||
std::string pretty_time(std::chrono::nanoseconds duration);
|
||||
float draw_device_panel(float panel_width,
|
||||
ux_window& window,
|
||||
std::string& error_message,
|
||||
viewer_model& viewer);
|
||||
void play_defaults(viewer_model& view);
|
||||
float draw_preset_panel(float panel_width,
|
||||
ux_window& window,
|
||||
std::string& error_message,
|
||||
viewer_model& viewer,
|
||||
bool update_read_only_options,
|
||||
bool load_json_if_streaming,
|
||||
json_loading_func json_loading);
|
||||
bool prompt_toggle_advanced_mode(bool enable_advanced_mode, const std::string& message_text,
|
||||
std::vector<std::string>& restarting_device_info,
|
||||
viewer_model& view,
|
||||
ux_window& window,
|
||||
const std::string& error_message);
|
||||
|
||||
void load_viewer_configurations(const std::string& json_str);
|
||||
void save_viewer_configurations(std::ofstream& outfile, rsutils::json& j);
|
||||
void handle_online_sw_update(
|
||||
std::shared_ptr< notifications_model > nm,
|
||||
std::shared_ptr< sw_update::dev_updates_profile::update_profile > update_profile,
|
||||
bool reset_delay = false );
|
||||
|
||||
bool handle_online_fw_update(
|
||||
const context & ctx,
|
||||
std::shared_ptr< notifications_model > nm,
|
||||
std::shared_ptr< sw_update::dev_updates_profile::update_profile > update_profile,
|
||||
bool reset_delay = false );
|
||||
|
||||
std::shared_ptr<recorder> _recorder;
|
||||
std::vector<std::shared_ptr<subdevice_model>> live_subdevices;
|
||||
rsutils::time::periodic_timer _update_readonly_options_timer;
|
||||
bool pause_required = false;
|
||||
std::shared_ptr< atomic_objects_in_frame > _detected_objects;
|
||||
std::shared_ptr<updates_model> _updates;
|
||||
std::shared_ptr<sw_update::dev_updates_profile::update_profile >_updates_profile;
|
||||
calibration_model _calib_model;
|
||||
};
|
||||
|
||||
std::pair<std::string, std::string> get_device_name(const device& dev);
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> get_devices_names(const device_list& list);
|
||||
|
||||
class device_changes
|
||||
{
|
||||
public:
|
||||
explicit device_changes(rs2::context& ctx);
|
||||
bool try_get_next_changes(event_information& removed_and_connected);
|
||||
private:
|
||||
void add_changes(const event_information& c);
|
||||
std::queue<event_information> _changes;
|
||||
std::mutex _mtx;
|
||||
};
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2024 Intel Corporation. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include <rsutils/number/float3.h>
|
||||
|
||||
|
||||
namespace rs2 {
|
||||
|
||||
|
||||
using rsutils::number::float2;
|
||||
|
||||
|
||||
} // namespace rs2
|
@ -0,0 +1,14 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2024 Intel Corporation. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include <rsutils/number/float3.h>
|
||||
|
||||
|
||||
namespace rs2 {
|
||||
|
||||
|
||||
using rsutils::number::float3;
|
||||
|
||||
|
||||
} // namespace rs2
|
@ -0,0 +1,15 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2021 Intel Corporation. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace rs2 {
|
||||
|
||||
|
||||
struct float4
|
||||
{
|
||||
float x, y, z, w;
|
||||
};
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,663 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
|
||||
|
||||
#include "fw-update-helper.h"
|
||||
#include "model-views.h"
|
||||
#include "viewer.h"
|
||||
#include "ux-window.h"
|
||||
|
||||
#include <rsutils/os/special-folder.h>
|
||||
#include "os.h"
|
||||
|
||||
#include <rsutils/easylogging/easyloggingpp.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <condition_variable>
|
||||
|
||||
#ifdef INTERNAL_FW
|
||||
#include "common/fw/D4XX_FW_Image.h"
|
||||
#else
|
||||
#define FW_D4XX_FW_IMAGE_VERSION ""
|
||||
const char* fw_get_D4XX_FW_Image(int) { return NULL; }
|
||||
|
||||
|
||||
#endif // INTERNAL_FW
|
||||
|
||||
constexpr const char* recommended_fw_url = "https://dev.intelrealsense.com/docs/firmware-updates";
|
||||
|
||||
namespace rs2
|
||||
{
|
||||
enum firmware_update_ui_state
|
||||
{
|
||||
RS2_FWU_STATE_INITIAL_PROMPT = 0,
|
||||
RS2_FWU_STATE_IN_PROGRESS = 1,
|
||||
RS2_FWU_STATE_COMPLETE = 2,
|
||||
RS2_FWU_STATE_FAILED = 3,
|
||||
};
|
||||
|
||||
bool is_recommended_fw_available(const std::string& product_line, const std::string& pid)
|
||||
{
|
||||
auto pl = parse_product_line(product_line);
|
||||
auto fv = get_available_firmware_version(pl, pid);
|
||||
return !(fv == "");
|
||||
}
|
||||
|
||||
int parse_product_line(const std::string& product_line)
|
||||
{
|
||||
if (product_line == "D400") return RS2_PRODUCT_LINE_D400;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
std::string get_available_firmware_version(int product_line, const std::string& pid)
|
||||
{
|
||||
if (product_line == RS2_PRODUCT_LINE_D400) return FW_D4XX_FW_IMAGE_VERSION;
|
||||
else return "";
|
||||
}
|
||||
|
||||
std::vector< uint8_t > get_default_fw_image( int product_line, const std::string & pid )
|
||||
{
|
||||
std::vector< uint8_t > image;
|
||||
|
||||
switch( product_line )
|
||||
{
|
||||
case RS2_PRODUCT_LINE_D400:
|
||||
{
|
||||
bool allow_rc_firmware = config_file::instance().get_or_default( configurations::update::allow_rc_firmware, false );
|
||||
if( strlen( FW_D4XX_FW_IMAGE_VERSION ) && ! allow_rc_firmware )
|
||||
{
|
||||
int size = 0;
|
||||
auto hex = fw_get_D4XX_FW_Image( size );
|
||||
image = std::vector< uint8_t >( hex, hex + size );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
bool is_upgradeable(const std::string& curr, const std::string& available)
|
||||
{
|
||||
if (curr == "" || available == "") return false;
|
||||
return rsutils::version( curr ) < rsutils::version( available );
|
||||
}
|
||||
|
||||
bool firmware_update_manager::check_for(
|
||||
std::function<bool()> action, std::function<void()> cleanup,
|
||||
std::chrono::system_clock::duration delta)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
|
||||
auto start = system_clock::now();
|
||||
auto now = system_clock::now();
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (action()) return true;
|
||||
}
|
||||
catch (const error& e)
|
||||
{
|
||||
fail(error_to_string(e));
|
||||
cleanup();
|
||||
return false;
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
fail(ex.what());
|
||||
cleanup();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail("Unknown error during update.\nPlease reconnect the camera to exit recovery mode");
|
||||
cleanup();
|
||||
return false;
|
||||
}
|
||||
|
||||
now = system_clock::now();
|
||||
this_thread::sleep_for(milliseconds(100));
|
||||
} while (now - start < delta);
|
||||
return false;
|
||||
}
|
||||
|
||||
void firmware_update_manager::process_mipi()
|
||||
{
|
||||
if (!_is_signed)
|
||||
{
|
||||
fail("Signed FW update for MIPI device - This FW file is not signed ");
|
||||
return;
|
||||
}
|
||||
auto dev_updatable = _dev.as<updatable>();
|
||||
if(!(dev_updatable && dev_updatable.check_firmware_compatibility(_fw)))
|
||||
{
|
||||
fail("Firmware Update failed - fw version must be newer than version 5.13.1.1");
|
||||
return;
|
||||
}
|
||||
|
||||
log("Burning Signed Firmware on MIPI device");
|
||||
|
||||
// Enter DFU mode
|
||||
auto device_debug = _dev.as<rs2::debug_protocol>();
|
||||
uint32_t dfu_opcode = 0x1e;
|
||||
device_debug.build_command(dfu_opcode, 1);
|
||||
|
||||
_progress = 30;
|
||||
|
||||
// Write signed firmware to appropriate file descriptor
|
||||
std::ofstream fw_path_in_device(_dev.get_info(RS2_CAMERA_INFO_DFU_DEVICE_PATH), std::ios::binary);
|
||||
if (fw_path_in_device)
|
||||
{
|
||||
fw_path_in_device.write(reinterpret_cast<const char*>(_fw.data()), _fw.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
fail("Firmware Update failed - wrong path or permissions missing");
|
||||
return;
|
||||
}
|
||||
LOG_INFO("Firmware Update for MIPI device done.");
|
||||
fw_path_in_device.close();
|
||||
|
||||
_progress = 100;
|
||||
_done = true;
|
||||
// need to find a way to update the fw version field in the viewer
|
||||
}
|
||||
|
||||
void firmware_update_manager::process_flow(
|
||||
std::function<void()> cleanup,
|
||||
invoker invoke)
|
||||
{
|
||||
// if device is D457, and fw is signed - using mipi specific procedure
|
||||
if (!strcmp(_dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID), "ABCD") && _is_signed)
|
||||
{
|
||||
process_mipi();
|
||||
return;
|
||||
}
|
||||
|
||||
std::string serial = "";
|
||||
if (_dev.supports(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID))
|
||||
serial = _dev.get_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID);
|
||||
else
|
||||
serial = _dev.query_sensors().front().get_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID);
|
||||
|
||||
// Clear FW update related notification to avoid dismissing the notification on ~device_model()
|
||||
// We want the notification alive during the whole process.
|
||||
_model.related_notifications.erase(
|
||||
std::remove_if( _model.related_notifications.begin(),
|
||||
_model.related_notifications.end(),
|
||||
[]( std::shared_ptr< notification_model > n ) {
|
||||
return n->is< fw_update_notification_model >();
|
||||
} ) , end(_model.related_notifications));
|
||||
|
||||
for (auto&& n : _model.related_notifications)
|
||||
{
|
||||
if (n->is< fw_update_notification_model >()
|
||||
|| n->is< sw_recommended_update_alert_model >())
|
||||
n->dismiss(false);
|
||||
}
|
||||
|
||||
_progress = 5;
|
||||
|
||||
int next_progress = 10;
|
||||
|
||||
update_device dfu{};
|
||||
|
||||
if (auto upd = _dev.as<updatable>())
|
||||
{
|
||||
// checking firmware version compatibility with device
|
||||
if (_is_signed)
|
||||
{
|
||||
if (!upd.check_firmware_compatibility(_fw))
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "The firmware version is not compatible with ";
|
||||
ss << _dev.get_info(RS2_CAMERA_INFO_NAME) << std::endl;
|
||||
fail(ss.str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log( "Trying to back-up camera flash memory" );
|
||||
|
||||
std::string log_backup_status;
|
||||
try
|
||||
{
|
||||
auto flash = upd.create_flash_backup( [&]( const float progress )
|
||||
{
|
||||
_progress = ( ( ceil( progress * 5 ) / 5 ) * ( 30 - next_progress ) ) + next_progress;
|
||||
} );
|
||||
|
||||
// Not all cameras supports this feature
|
||||
if( !flash.empty() )
|
||||
{
|
||||
auto temp = rsutils::os::get_special_folder( rsutils::os::special_folder::app_data );
|
||||
temp += serial + "." + get_timestamped_file_name() + ".bin";
|
||||
|
||||
{
|
||||
std::ofstream file( temp.c_str(), std::ios::binary );
|
||||
file.write( (const char*)flash.data(), flash.size() );
|
||||
log_backup_status = "Backup completed and saved as '" + temp + "'";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log_backup_status = "Backup flash is not supported";
|
||||
}
|
||||
}
|
||||
catch( const std::exception& e )
|
||||
{
|
||||
if( auto not_model_protected = get_protected_notification_model() )
|
||||
{
|
||||
log_backup_status = "WARNING: backup failed; continuing without it...";
|
||||
not_model_protected->output.add_log( RS2_LOG_SEVERITY_WARN,
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
log_backup_status + ", Error: " + e.what() );
|
||||
}
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
if( auto not_model_protected = get_protected_notification_model() )
|
||||
{
|
||||
log_backup_status = "WARNING: backup failed; continuing without it...";
|
||||
not_model_protected->add_log( log_backup_status + ", Unknown error occurred" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !log_backup_status.empty() )
|
||||
log(log_backup_status);
|
||||
|
||||
|
||||
|
||||
|
||||
next_progress = 40;
|
||||
|
||||
if (_is_signed)
|
||||
{
|
||||
log("Requesting to switch to recovery mode");
|
||||
|
||||
// in order to update device to DFU state, it will be disconnected then switches to DFU state
|
||||
// if querying devices is called while device still switching to DFU state, an exception will be thrown
|
||||
// to prevent that, a blocking is added to make sure device is updated before continue to next step of querying device
|
||||
upd.enter_update_state();
|
||||
|
||||
if (!check_for([this, serial, &dfu]() {
|
||||
auto devs = _ctx.query_devices();
|
||||
|
||||
for (uint32_t j = 0; j < devs.size(); j++)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto d = devs[j];
|
||||
if (d.is<update_device>())
|
||||
{
|
||||
if (d.supports(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID))
|
||||
{
|
||||
if (serial == d.get_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID))
|
||||
{
|
||||
log( "DFU device '" + serial + "' found" );
|
||||
dfu = d;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception &e) {
|
||||
if (auto not_model_protected = get_protected_notification_model())
|
||||
{
|
||||
not_model_protected->output.add_log(RS2_LOG_SEVERITY_WARN,
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
rsutils::string::from() << "Exception caught in FW Update process-flow: " << e.what() << "; Retrying...");
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
|
||||
return false;
|
||||
}, cleanup, std::chrono::seconds(60)))
|
||||
{
|
||||
fail("Recovery device did not connect in time!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dfu = _dev.as<update_device>();
|
||||
}
|
||||
|
||||
if (dfu)
|
||||
{
|
||||
_progress = float(next_progress);
|
||||
|
||||
log("Recovery device connected, starting update..\n"
|
||||
"Internal write is in progress\n"
|
||||
"Please DO NOT DISCONNECT the camera");
|
||||
|
||||
dfu.update(_fw, [&](const float progress)
|
||||
{
|
||||
_progress = ((ceil(progress * 10) / 10 * (90 - next_progress)) + next_progress);
|
||||
});
|
||||
|
||||
log( "Firmware Download completed, await DFU transition event" );
|
||||
std::this_thread::sleep_for( std::chrono::seconds( 3 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto upd = _dev.as<updatable>();
|
||||
upd.update_unsigned(_fw, [&](const float progress)
|
||||
{
|
||||
_progress = (ceil(progress * 10) / 10 * (90 - next_progress)) + next_progress;
|
||||
});
|
||||
log("Firmware Update completed, waiting for device to reconnect");
|
||||
}
|
||||
|
||||
if (!check_for([this, serial]() {
|
||||
auto devs = _ctx.query_devices();
|
||||
|
||||
for (uint32_t j = 0; j < devs.size(); j++)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto d = devs[j];
|
||||
|
||||
if (d.query_sensors().size() && d.query_sensors().front().supports(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID))
|
||||
{
|
||||
auto s = d.query_sensors().front().get_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID);
|
||||
if (s == serial)
|
||||
{
|
||||
log("Discovered connection of the original device");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
|
||||
return false;
|
||||
}, cleanup, std::chrono::seconds(60)))
|
||||
{
|
||||
fail("Original device did not reconnect in time!");
|
||||
return;
|
||||
}
|
||||
|
||||
log( "Device reconnected successfully!\n"
|
||||
"FW update process completed successfully" );
|
||||
|
||||
_progress = 100;
|
||||
|
||||
_done = true;
|
||||
}
|
||||
|
||||
void fw_update_notification_model::draw_content(ux_window& win, int x, int y, float t, std::string& error_message)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace chrono;
|
||||
|
||||
ImGui::SetCursorScreenPos({ float(x + 9), float(y + 4) });
|
||||
|
||||
ImVec4 shadow{ 1.f, 1.f, 1.f, 0.1f };
|
||||
ImGui::GetWindowDrawList()->AddRectFilled({ float(x), float(y) },
|
||||
{ float(x + width), float(y + 25) }, ImColor(shadow));
|
||||
|
||||
if (update_state != RS2_FWU_STATE_COMPLETE)
|
||||
{
|
||||
ImGui::Text("Firmware Update Recommended!");
|
||||
|
||||
ImGui::SetCursorScreenPos({ float(x + 5), float(y + 27) });
|
||||
|
||||
draw_text(get_title().c_str(), x, y, height - 50);
|
||||
|
||||
ImGui::SetCursorScreenPos({ float(x + 9), float(y + height - 67) });
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, alpha(light_grey, 1.f - t));
|
||||
|
||||
if (update_state == RS2_FWU_STATE_INITIAL_PROMPT)
|
||||
ImGui::Text("Firmware updates offer critical bug fixes and\nunlock new camera capabilities.");
|
||||
else
|
||||
ImGui::Text("Firmware update is underway...\nPlease do not disconnect the device");
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
//ImGui::PushStyleColor(ImGuiCol_Text, alpha(light_blue, 1.f - t));
|
||||
ImGui::Text("Update Completed");
|
||||
//ImGui::PopStyleColor();
|
||||
|
||||
ImGui::SetCursorScreenPos({ float(x + 10), float(y + 35) });
|
||||
ImGui::PushFont(win.get_large_font());
|
||||
std::string txt = rsutils::string::from() << textual_icons::throphy;
|
||||
ImGui::Text("%s", txt.c_str());
|
||||
ImGui::PopFont();
|
||||
|
||||
ImGui::SetCursorScreenPos({ float(x + 40), float(y + 35) });
|
||||
ImGui::Text("Camera Firmware Updated Successfully");
|
||||
}
|
||||
|
||||
ImGui::SetCursorScreenPos({ float(x + 5), float(y + height - 25) });
|
||||
|
||||
const auto bar_width = width - 115;
|
||||
|
||||
if (update_manager)
|
||||
{
|
||||
if (update_state == RS2_FWU_STATE_INITIAL_PROMPT)
|
||||
{
|
||||
auto sat = 1.f + sin(duration_cast<milliseconds>(system_clock::now() - created_time).count() / 700.f) * 0.1f;
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, saturate(sensor_header_light_blue, sat));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, saturate(sensor_header_light_blue, 1.5f));
|
||||
std::string button_name = rsutils::string::from() << "Install" << "##fwupdate" << index;
|
||||
|
||||
if (ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }) || update_manager->started())
|
||||
{
|
||||
// stopping stream before starting fw update
|
||||
auto fw_update_manager = dynamic_cast<firmware_update_manager*>(update_manager.get());
|
||||
if( ! fw_update_manager )
|
||||
throw std::runtime_error( "Cannot convert firmware_update_manager" );
|
||||
std::for_each(fw_update_manager->get_device_model().subdevices.begin(),
|
||||
fw_update_manager->get_device_model().subdevices.end(),
|
||||
[&](const std::shared_ptr<subdevice_model>& sm)
|
||||
{
|
||||
if (sm->streaming)
|
||||
{
|
||||
try
|
||||
{
|
||||
sm->stop(fw_update_manager->get_protected_notification_model());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// avoiding exception that can be sent by stop method
|
||||
// this could happen if the sensor is not streaming and the stop method is called - for example
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
auto _this = shared_from_this();
|
||||
auto invoke = [_this](std::function<void()> action) {
|
||||
_this->invoke(action);
|
||||
};
|
||||
|
||||
if (!update_manager->started())
|
||||
update_manager->start(invoke);
|
||||
|
||||
update_state = RS2_FWU_STATE_IN_PROGRESS;
|
||||
enable_dismiss = false;
|
||||
_progress_bar.last_progress_time = system_clock::now();
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::SetTooltip("%s", "New firmware will be flashed to the device");
|
||||
}
|
||||
}
|
||||
else if (update_state == RS2_FWU_STATE_IN_PROGRESS)
|
||||
{
|
||||
if (update_manager->done())
|
||||
{
|
||||
update_state = RS2_FWU_STATE_COMPLETE;
|
||||
pinned = false;
|
||||
_progress_bar.last_progress_time = last_interacted = system_clock::now();
|
||||
}
|
||||
|
||||
if (!expanded)
|
||||
{
|
||||
if (update_manager->failed())
|
||||
{
|
||||
update_manager->check_error(error_message);
|
||||
update_state = RS2_FWU_STATE_FAILED;
|
||||
pinned = false;
|
||||
dismiss(false);
|
||||
}
|
||||
|
||||
draw_progress_bar(win, bar_width);
|
||||
|
||||
ImGui::SetCursorScreenPos({ float(x + width - 105), float(y + height - 25) });
|
||||
|
||||
string id = rsutils::string::from() << "Expand" << "##" << index;
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, light_grey);
|
||||
if (ImGui::Button(id.c_str(), { 100, 20 }))
|
||||
{
|
||||
expanded = true;
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string button_name = rsutils::string::from() << "Learn More..." << "##" << index;
|
||||
|
||||
if (ImGui::Button(button_name.c_str(), { float(bar_width), 20 }))
|
||||
{
|
||||
open_url(recommended_fw_url);
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
win.link_hovered();
|
||||
ImGui::SetTooltip("%s", "Internet connection required");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fw_update_notification_model::draw_expanded(ux_window& win, std::string& error_message)
|
||||
{
|
||||
if (update_manager->started() && update_state == RS2_FWU_STATE_INITIAL_PROMPT)
|
||||
update_state = RS2_FWU_STATE_IN_PROGRESS;
|
||||
|
||||
auto flags = ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoCollapse;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, { 0, 0, 0, 0 });
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, light_grey);
|
||||
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, white);
|
||||
ImGui::PushStyleColor(ImGuiCol_PopupBg, sensor_bg);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(500, 100));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(5, 5));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0);
|
||||
|
||||
std::string title = "Firmware Update";
|
||||
if (update_manager->failed()) title += " Failed";
|
||||
|
||||
ImGui::OpenPopup(title.c_str());
|
||||
if (ImGui::BeginPopupModal(title.c_str(), nullptr, flags))
|
||||
{
|
||||
ImGui::SetCursorPosX(200);
|
||||
std::string progress_str = rsutils::string::from() << "Progress: " << update_manager->get_progress() << "%";
|
||||
ImGui::Text("%s", progress_str.c_str());
|
||||
|
||||
ImGui::SetCursorPosX(5);
|
||||
|
||||
draw_progress_bar(win, 490);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, regular_blue);
|
||||
auto s = update_manager->get_log();
|
||||
ImGui::InputTextMultiline("##fw_update_log", const_cast<char*>(s.c_str()),
|
||||
s.size() + 1, { 490,100 }, ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_ReadOnly);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::SetCursorPosX(190);
|
||||
if (visible || update_manager->done() || update_manager->failed())
|
||||
{
|
||||
if (ImGui::Button("OK", ImVec2(120, 0)))
|
||||
{
|
||||
if (update_manager->done() || update_manager->failed())
|
||||
{
|
||||
update_state = RS2_FWU_STATE_FAILED;
|
||||
pinned = false;
|
||||
dismiss(false);
|
||||
}
|
||||
expanded = false;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, transparent);
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, transparent);
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, transparent);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, transparent);
|
||||
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, transparent);
|
||||
ImGui::Button("OK", ImVec2(120, 0));
|
||||
ImGui::PopStyleColor(5);
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(3);
|
||||
ImGui::PopStyleColor(4);
|
||||
|
||||
error_message = "";
|
||||
}
|
||||
|
||||
int fw_update_notification_model::calc_height()
|
||||
{
|
||||
if (update_state != RS2_FWU_STATE_COMPLETE) return 150;
|
||||
else return 65;
|
||||
}
|
||||
|
||||
void fw_update_notification_model::set_color_scheme(float t) const
|
||||
{
|
||||
notification_model::set_color_scheme(t);
|
||||
|
||||
ImGui::PopStyleColor(1);
|
||||
|
||||
ImVec4 c;
|
||||
|
||||
if (update_state == RS2_FWU_STATE_COMPLETE)
|
||||
{
|
||||
c = alpha(saturate(light_blue, 0.7f), 1 - t);
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, c);
|
||||
}
|
||||
else
|
||||
{
|
||||
c = alpha(sensor_bg, 1 - t);
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, c);
|
||||
}
|
||||
}
|
||||
|
||||
fw_update_notification_model::fw_update_notification_model(std::string name,
|
||||
std::shared_ptr<firmware_update_manager> manager, bool exp)
|
||||
: process_notification_model(manager)
|
||||
{
|
||||
enable_expand = false;
|
||||
expanded = exp;
|
||||
if (expanded) visible = false;
|
||||
|
||||
message = name;
|
||||
this->severity = RS2_LOG_SEVERITY_INFO;
|
||||
this->category = RS2_NOTIFICATION_CATEGORY_FIRMWARE_UPDATE_RECOMMENDED;
|
||||
pinned = true;
|
||||
forced = true;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "notifications.h"
|
||||
|
||||
|
||||
namespace rs2
|
||||
{
|
||||
class viewer_model;
|
||||
|
||||
int parse_product_line(const std::string& product_line);
|
||||
std::string get_available_firmware_version(int product_line, const std::string& pid);
|
||||
|
||||
std::vector<uint8_t> get_default_fw_image(int product_line, const std::string& pid);
|
||||
bool is_upgradeable(const std::string& curr, const std::string& available);
|
||||
bool is_recommended_fw_available(const std::string& product_line, const std::string& pid);
|
||||
|
||||
class firmware_update_manager : public process_manager
|
||||
{
|
||||
public:
|
||||
firmware_update_manager(std::shared_ptr<notifications_model> not_model, device_model& model, device dev, context ctx, std::vector<uint8_t> fw, bool is_signed)
|
||||
: process_manager("Firmware Update"), _not_model(not_model), _model(model),
|
||||
_fw(fw), _is_signed(is_signed), _dev(dev), _ctx(ctx) {}
|
||||
|
||||
const device_model& get_device_model() const { return _model; }
|
||||
std::shared_ptr<notifications_model> get_protected_notification_model() { return _not_model.lock(); };
|
||||
|
||||
protected:
|
||||
void process_flow(std::function<void()> cleanup,
|
||||
invoker invoke) override;
|
||||
void process_mipi();
|
||||
bool check_for(
|
||||
std::function<bool()> action, std::function<void()> cleanup,
|
||||
std::chrono::system_clock::duration delta);
|
||||
|
||||
std::weak_ptr<notifications_model> _not_model;
|
||||
device _dev;
|
||||
context _ctx;
|
||||
std::vector<uint8_t> _fw;
|
||||
bool _is_signed;
|
||||
device_model& _model;
|
||||
bool _is_d500_device = false;
|
||||
};
|
||||
|
||||
struct fw_update_notification_model : public process_notification_model
|
||||
{
|
||||
fw_update_notification_model(std::string name,
|
||||
std::shared_ptr<firmware_update_manager> manager, bool expaned);
|
||||
|
||||
void set_color_scheme(float t) const override;
|
||||
void draw_content(ux_window& win, int x, int y, float t, std::string& error_message) override;
|
||||
void draw_expanded(ux_window& win, std::string& error_message) override;
|
||||
int calc_height() override;
|
||||
};
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
# License: Apache 2.0. See LICENSE file in root directory.
|
||||
# Copyright(c) 2019 Intel Corporation. All Rights Reserved.
|
||||
cmake_minimum_required(VERSION 3.1.3)
|
||||
|
||||
project(fw)
|
||||
|
||||
file(READ "firmware-version.h" ver)
|
||||
|
||||
message(STATUS "Fetching recommended firmwares:")
|
||||
|
||||
set(REALSENSE_FIRMWARE_URL "https://librealsense.intel.com" CACHE STRING
|
||||
"URL to download firmware binaries from")
|
||||
|
||||
string(REGEX MATCH "D4XX_RECOMMENDED_FIRMWARE_VERSION \"([0-9]+.[0-9]+.[0-9]+.[0-9]+)\"" _ ${ver})
|
||||
set(D4XX_FW_VERSION ${CMAKE_MATCH_1})
|
||||
#message(STATUS "D4XX_FW_VERSION: ${D4XX_FW_VERSION}")
|
||||
set(D4XX_FW_SHA1 51e37fd01132c500bb4e4af408a41f42391289a5)
|
||||
set(D4XX_FW_URL "${REALSENSE_FIRMWARE_URL}/Releases/RS4xx/FW")
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC empty.c)
|
||||
|
||||
# disable link time optimization for fw by adding -fno-lto to disable -flto flag
|
||||
# jammy debian has build errors without it
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
message(STATUS "disable link time optimization for fw project")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -fno-lto)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
# lib.exe can't handle multiple .res files, so include them in one.
|
||||
# even then, the linker won't grab a .res out of a .lib object, so it needs to be explicitly listed
|
||||
# and to find the name of the .res file (across cmake generators) we need to create our own rule. :(
|
||||
add_custom_command(TARGET ${PROJECT_NAME} BYPRODUCTS ${PROJECT_NAME}.res COMMAND ${CMAKE_RC_COMPILER} ${CMAKE_RC_FLAGS} /I . /fo "${PROJECT_NAME}.res" "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.rc")
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.res")
|
||||
endif()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
||||
set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER Resources)
|
||||
|
||||
function(target_binary url version sha1 symbol ext)
|
||||
set(binary "${CMAKE_CURRENT_BINARY_DIR}/${symbol}-${version}${ext}")
|
||||
message(STATUS "... ${url}/${symbol}-${version}${ext}")
|
||||
file(DOWNLOAD "${url}/${symbol}-${version}${ext}" "${binary}"
|
||||
EXPECTED_HASH SHA1=${sha1}
|
||||
STATUS status)
|
||||
list(GET status 0 error_code)
|
||||
if (NOT ${error_code} EQUAL 0)
|
||||
message(FATAL_ERROR "FAILED with status ${status}")
|
||||
else()
|
||||
#message(STATUS "Download firmware ${status} for ${symbol}-${version}${ext}")
|
||||
endif()
|
||||
string(TOUPPER ${symbol} SYMBOL)
|
||||
string(REPLACE "." "," version_commas ${version})
|
||||
string(REPLACE "\\" "\\\\" binary_escaped "${binary}")
|
||||
configure_file(fw.c.in "${CMAKE_CURRENT_BINARY_DIR}/${symbol}.c" @ONLY)
|
||||
configure_file(fw.h.in "${CMAKE_CURRENT_BINARY_DIR}/${symbol}.h" @ONLY)
|
||||
configure_file(fw.rc.in "${CMAKE_CURRENT_BINARY_DIR}/${symbol}.rc" @ONLY)
|
||||
if (MSVC)
|
||||
enable_language(RC)
|
||||
set_source_files_properties("${PROJECT_NAME}.rc" OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${symbol}.rc")
|
||||
set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${symbol}.rc" OBJECT_DEPENDS "${binary}")
|
||||
else()
|
||||
set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${symbol}.c" OBJECT_DEPENDS "${binary}")
|
||||
endif()
|
||||
target_sources(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${symbol}.c")
|
||||
endfunction()
|
||||
|
||||
target_binary( "${D4XX_FW_URL}" "${D4XX_FW_VERSION}" "${D4XX_FW_SHA1}" D4XX_FW_Image .bin)
|
||||
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} EXPORT realsense2Targets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
@ -0,0 +1 @@
|
||||
int fw_empty; // avoid warnings about empty.o being an empty object
|
@ -0,0 +1,7 @@
|
||||
/* License: Apache 2.0. See LICENSE file in root directory.
|
||||
Copyright(c) 2017-24 Intel Corporation. All Rights Reserved. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#define D4XX_RECOMMENDED_FIRMWARE_VERSION "5.16.0.1"
|
||||
|
@ -0,0 +1,25 @@
|
||||
// All included firmware files are
|
||||
// INTEL CORPORATION PROPRIETARY INFORMATION
|
||||
// Copyright(c) 2019 Intel Corporation. All Rights Reserved
|
||||
const int fw_@symbol@_version[4] = {@version_commas@};
|
||||
#ifndef _MSC_VER
|
||||
__asm__(
|
||||
"#version @sha1@\n"
|
||||
#ifdef __APPLE__
|
||||
".const_data\n"
|
||||
#define _ "_"
|
||||
#else
|
||||
".section .rodata\n"
|
||||
#define _ ""
|
||||
#endif
|
||||
".global "_"fw_@symbol@_data\n"
|
||||
_"fw_@symbol@_data:\n"
|
||||
".incbin \"@binary_escaped@\"\n"
|
||||
".global "_"fw_@symbol@_size\n"
|
||||
_"fw_@symbol@_size:\n"
|
||||
"1:\n"
|
||||
".int 1b - "_"fw_@symbol@_data\n"
|
||||
".previous"
|
||||
);
|
||||
#undef _
|
||||
#endif
|
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#define FW_@SYMBOL@_VERSION "@version@"
|
||||
|
||||
extern "C" const unsigned char fw_@symbol@_data[];
|
||||
extern "C" const int fw_@symbol@_size;
|
||||
extern "C" const int fw_@symbol@_version[4];
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <windows.h>
|
||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||
#endif
|
||||
|
||||
static inline const unsigned char *fw_get_@symbol@(int &size)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
HRSRC rc = ::FindResourceA((HMODULE)&__ImageBase, "@SYMBOL@_DATA" , "@SYMBOL@_RC");
|
||||
HGLOBAL data = ::LoadResource((HMODULE)&__ImageBase, rc);
|
||||
size = ::SizeofResource((HMODULE)&__ImageBase, rc);
|
||||
return static_cast<const unsigned char*>(::LockResource(data));
|
||||
#else
|
||||
size = fw_@symbol@_size;
|
||||
return fw_@symbol@_data;
|
||||
#endif
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
#include "D4XX_FW_Image.rc"
|
||||
|
@ -0,0 +1 @@
|
||||
@SYMBOL@_DATA @SYMBOL@_RC "@binary_escaped@"
|
@ -0,0 +1,196 @@
|
||||
// License: Apache 2.0. See LICENSE file in root directory.
|
||||
// Copyright(c) 2021 Intel Corporation. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <librealsense2/h/rs_types.h> // rs2_quaternion
|
||||
#include "float4.h"
|
||||
|
||||
#include <cmath> // sqrt
|
||||
#include <cstring> // memset
|
||||
|
||||
|
||||
namespace rs2 {
|
||||
|
||||
|
||||
struct matrix4
|
||||
{
|
||||
float mat[4][4];
|
||||
|
||||
operator float*() const
|
||||
{
|
||||
return (float*)&mat;
|
||||
}
|
||||
|
||||
static matrix4 identity()
|
||||
{
|
||||
matrix4 m;
|
||||
for (int i = 0; i < 4; i++)
|
||||
m.mat[i][i] = 1.f;
|
||||
return m;
|
||||
}
|
||||
|
||||
matrix4()
|
||||
{
|
||||
std::memset(mat, 0, sizeof(mat));
|
||||
}
|
||||
|
||||
matrix4(float vals[4][4])
|
||||
{
|
||||
std::memcpy(mat,vals,sizeof(mat));
|
||||
}
|
||||
|
||||
// convert glGetFloatv output to matrix4
|
||||
//
|
||||
// float m[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
// into
|
||||
// rs2::matrix4 m = { {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15} };
|
||||
// 0 1 2 3
|
||||
// 4 5 6 7
|
||||
// 8 9 10 11
|
||||
// 12 13 14 15
|
||||
matrix4(float vals[16])
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
mat[i][j] = vals[i * 4 + j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float& operator()(int i, int j) { return mat[i][j]; }
|
||||
const float& operator()(int i, int j) const { return mat[i][j]; }
|
||||
|
||||
//init rotation matrix from quaternion
|
||||
matrix4(const rs2_quaternion& q)
|
||||
{
|
||||
mat[0][0] = 1 - 2*q.y*q.y - 2*q.z*q.z; mat[0][1] = 2*q.x*q.y - 2*q.z*q.w; mat[0][2] = 2*q.x*q.z + 2*q.y*q.w; mat[0][3] = 0.0f;
|
||||
mat[1][0] = 2*q.x*q.y + 2*q.z*q.w; mat[1][1] = 1 - 2*q.x*q.x - 2*q.z*q.z; mat[1][2] = 2*q.y*q.z - 2*q.x*q.w; mat[1][3] = 0.0f;
|
||||
mat[2][0] = 2*q.x*q.z - 2*q.y*q.w; mat[2][1] = 2*q.y*q.z + 2*q.x*q.w; mat[2][2] = 1 - 2*q.x*q.x - 2*q.y*q.y; mat[2][3] = 0.0f;
|
||||
mat[3][0] = 0.0f; mat[3][1] = 0.0f; mat[3][2] = 0.0f; mat[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
//init translation matrix from vector
|
||||
matrix4(const rs2_vector& t)
|
||||
{
|
||||
mat[0][0] = 1.0f; mat[0][1] = 0.0f; mat[0][2] = 0.0f; mat[0][3] = t.x;
|
||||
mat[1][0] = 0.0f; mat[1][1] = 1.0f; mat[1][2] = 0.0f; mat[1][3] = t.y;
|
||||
mat[2][0] = 0.0f; mat[2][1] = 0.0f; mat[2][2] = 1.0f; mat[2][3] = t.z;
|
||||
mat[3][0] = 0.0f; mat[3][1] = 0.0f; mat[3][2] = 0.0f; mat[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
rs2_quaternion normalize(rs2_quaternion a)
|
||||
{
|
||||
float norm = sqrtf(a.x*a.x + a.y*a.y + a.z*a.z + a.w*a.w);
|
||||
rs2_quaternion res = a;
|
||||
res.x /= norm;
|
||||
res.y /= norm;
|
||||
res.z /= norm;
|
||||
res.w /= norm;
|
||||
return res;
|
||||
}
|
||||
|
||||
rs2_quaternion to_quaternion()
|
||||
{
|
||||
float tr[4];
|
||||
rs2_quaternion res;
|
||||
tr[0] = (mat[0][0] + mat[1][1] + mat[2][2]);
|
||||
tr[1] = (mat[0][0] - mat[1][1] - mat[2][2]);
|
||||
tr[2] = (-mat[0][0] + mat[1][1] - mat[2][2]);
|
||||
tr[3] = (-mat[0][0] - mat[1][1] + mat[2][2]);
|
||||
if (tr[0] >= tr[1] && tr[0] >= tr[2] && tr[0] >= tr[3])
|
||||
{
|
||||
float s = 2 * sqrt(tr[0] + 1);
|
||||
res.w = s / 4;
|
||||
res.x = (mat[2][1] - mat[1][2]) / s;
|
||||
res.y = (mat[0][2] - mat[2][0]) / s;
|
||||
res.z = (mat[1][0] - mat[0][1]) / s;
|
||||
}
|
||||
else if (tr[1] >= tr[2] && tr[1] >= tr[3]) {
|
||||
float s = 2 * sqrt(tr[1] + 1);
|
||||
res.w = (mat[2][1] - mat[1][2]) / s;
|
||||
res.x = s / 4;
|
||||
res.y = (mat[1][0] + mat[0][1]) / s;
|
||||
res.z = (mat[2][0] + mat[0][2]) / s;
|
||||
}
|
||||
else if (tr[2] >= tr[3]) {
|
||||
float s = 2 * sqrt(tr[2] + 1);
|
||||
res.w = (mat[0][2] - mat[2][0]) / s;
|
||||
res.x = (mat[1][0] + mat[0][1]) / s;
|
||||
res.y = s / 4;
|
||||
res.z = (mat[1][2] + mat[2][1]) / s;
|
||||
}
|
||||
else {
|
||||
float s = 2 * sqrt(tr[3] + 1);
|
||||
res.w = (mat[1][0] - mat[0][1]) / s;
|
||||
res.x = (mat[0][2] + mat[2][0]) / s;
|
||||
res.y = (mat[1][2] + mat[2][1]) / s;
|
||||
res.z = s / 4;
|
||||
}
|
||||
return normalize(res);
|
||||
}
|
||||
|
||||
void to_column_major(float column_major[16])
|
||||
{
|
||||
column_major[0] = mat[0][0];
|
||||
column_major[1] = mat[1][0];
|
||||
column_major[2] = mat[2][0];
|
||||
column_major[3] = mat[3][0];
|
||||
column_major[4] = mat[0][1];
|
||||
column_major[5] = mat[1][1];
|
||||
column_major[6] = mat[2][1];
|
||||
column_major[7] = mat[3][1];
|
||||
column_major[8] = mat[0][2];
|
||||
column_major[9] = mat[1][2];
|
||||
column_major[10] = mat[2][2];
|
||||
column_major[11] = mat[3][2];
|
||||
column_major[12] = mat[0][3];
|
||||
column_major[13] = mat[1][3];
|
||||
column_major[14] = mat[2][3];
|
||||
column_major[15] = mat[3][3];
|
||||
}
|
||||
};
|
||||
|
||||
inline matrix4 operator*(const matrix4& a, const matrix4& b)
|
||||
{
|
||||
matrix4 res;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
float sum = 0.0f;
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
sum += a.mat[i][k] * b.mat[k][j];
|
||||
}
|
||||
res.mat[i][j] = sum;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
inline float4 operator*(const matrix4& a, const float4& b)
|
||||
{
|
||||
float4 res;
|
||||
int i = 0;
|
||||
res.x = a(i, 0) * b.x + a(i, 1) * b.y + a(i, 2) * b.z + a(i, 3) * b.w; i++;
|
||||
res.y = a(i, 0) * b.x + a(i, 1) * b.y + a(i, 2) * b.z + a(i, 3) * b.w; i++;
|
||||
res.z = a(i, 0) * b.x + a(i, 1) * b.y + a(i, 2) * b.z + a(i, 3) * b.w; i++;
|
||||
res.w = a(i, 0) * b.x + a(i, 1) * b.y + a(i, 2) * b.z + a(i, 3) * b.w; i++;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
inline matrix4 identity_matrix()
|
||||
{
|
||||
matrix4 data;
|
||||
for( int i = 0; i < 4; i++ )
|
||||
for( int j = 0; j < 4; j++ )
|
||||
data.mat[i][j] = (i == j) ? 1.f : 0.f;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
} // namespace rs2
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue