Skip to content

Commit 1bc9233

Browse files
committed
Lint fix
Signed-off-by: Wendell Hom <whom@nvidia.com>
1 parent dc3d632 commit 1bc9233

File tree

9 files changed

+98
-89
lines changed

9 files changed

+98
-89
lines changed

applications/stereo_vision/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ using. This can be found using `v4l2-ctl --list-devices`.
4040

4141
## Models
4242

43-
This demo requires the ESS DNN Stereo Disparity availible from the NGC catalog for disparity and the
43+
This demo requires the ESS DNN Stereo Disparity available from the NGC catalog for disparity and the
4444
YOLOv8 onnx model for object detection. Both models are downloaded when you build the application.
4545

4646
### ESS DNN

applications/stereo_vision/cpp/crop.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ void CropOp::compute(InputContext& op_input, OutputContext& op_output, Execution
5353
int element_size = nvidia::gxf::PrimitiveTypeSize(data_type);
5454

5555
if (x_ < 0 || y_ < 0 || width_ <= 0 || height_ <= 0) {
56-
throw std::runtime_error("Invalide crop dimensions");
56+
throw std::runtime_error("Invalid crop dimensions");
5757
}
5858

5959
if ((x_ + width_) > orig_width || (y_ + height_) > orig_height) {
6060
std::cout << "orig_width " << orig_width << std::endl;
6161
std::cout << "orig_height " << orig_height << std::endl;
6262
std::cout << "nChannels " << nChannels << std::endl;
63-
throw std::runtime_error("Crop exceeds image boundries");
63+
throw std::runtime_error("Crop exceeds image boundaries");
6464
}
6565

6666
auto pointer = std::shared_ptr<void*>(new void*, [](void** pointer) {

applications/stereo_vision/cpp/crop.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424

2525
namespace holoscan::ops {
2626

27-
class CropOp : public Operator{
28-
public:
29-
HOLOSCAN_OPERATOR_FORWARD_ARGS(CropOp);
30-
CropOp() = default;
31-
void setup(OperatorSpec& spec) override;
32-
void compute(InputContext&, OutputContext& op_output, ExecutionContext&) override;
33-
private:
34-
Parameter<int> x_;
35-
Parameter<int> y_;
36-
Parameter<int> width_;
37-
Parameter<int> height_;
38-
};
27+
class CropOp : public Operator{
28+
public:
29+
HOLOSCAN_OPERATOR_FORWARD_ARGS(CropOp);
30+
CropOp() = default;
31+
void setup(OperatorSpec& spec) override;
32+
void compute(InputContext&, OutputContext& op_output, ExecutionContext&) override;
33+
private:
34+
Parameter<int> x_;
35+
Parameter<int> y_;
36+
Parameter<int> width_;
37+
Parameter<int> height_;
38+
};
3939

40-
}
40+
} // namespace holoscan::ops
4141
#endif

applications/stereo_vision/cpp/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class StereoDepthApp : public holoscan::Application {
4242
std::string stereo_calibration_;
4343

4444
public:
45-
StereoDepthApp(std::string file) : stereo_calibration_(file) {};
45+
explicit StereoDepthApp(std::string file) : stereo_calibration_(file) {}
4646
void compose() override {
4747
using namespace holoscan;
4848
YAML::Node calibration = YAML::LoadFile(stereo_calibration_);

applications/stereo_vision/cpp/split_video.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void SplitVideoOp::setup(OperatorSpec& spec) {
3434
spec.param(stereo_video_layout_,
3535
"stereo_video_layout",
3636
"Stereo Video Layout",
37-
"Horizontal or Vertical Concatination of Stereo Video Frames",
37+
"Horizontal or Vertical Concatenation of Stereo Video Frames",
3838
STEREO_VIDEO_HORIZONTAL);
3939
}
4040

@@ -142,7 +142,7 @@ void MergeVideoOp::setup(OperatorSpec& spec) {
142142
spec.param(stereo_video_layout_,
143143
"stereo_video_layout",
144144
"Stereo Video Layout",
145-
"Horizontal or Vertical Concatination of Stereo Video Frames",
145+
"Horizontal or Vertical Concatenation of Stereo Video Frames",
146146
STEREO_VIDEO_HORIZONTAL);
147147
}
148148

applications/stereo_vision/cpp/tracking_postprocessor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void TrackingPostprocessor::compute(InputContext& op_input, OutputContext& op_ou
5555
int scores_N = detection_boxes->shape()[1];
5656

5757
if (!(boxes_batch == 1 && scores_batch == 1 && boxes_N == scores_N && boxes_coord == 4)) {
58-
throw std::runtime_error("Wrong input dimentions for yolo input");
58+
throw std::runtime_error("Wrong input dimensions for yolo input");
5959
}
6060

6161
auto maybe_tensormap = op_input.receive<holoscan::TensorMap>("image");

applications/stereo_vision/cpp/tracking_postprocessor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TrackingPostprocessor : public Operator {
3030
void setup(OperatorSpec& spec) override;
3131
void compute(InputContext&, OutputContext& op_output, ExecutionContext&) override;
3232

33-
private:
33+
private:
3434
Parameter<float> score_threshold_;
3535
Parameter<int> bb_width_;
3636
Parameter<int> bb_height_;

applications/stereo_vision/cpp/undistort_rectify.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class UndistortRectifyOp : public Operator {
3333
public:
3434
class RectificationMap {
3535
public:
36-
RectificationMap() {};
36+
RectificationMap() {}
3737
RectificationMap(float* M, float* d, float* R, float* P, int width, int height);
3838
~RectificationMap();
3939
void setParameters(float* M, float* d, float* R, float* P, int width, int height);
@@ -55,7 +55,7 @@ class UndistortRectifyOp : public Operator {
5555
void compute(InputContext&, OutputContext& op_output, ExecutionContext&) override;
5656
void setRectificationMap(std::shared_ptr<RectificationMap> rectification_map) {
5757
rectification_map_ = rectification_map;
58-
};
58+
}
5959

6060
private:
6161
std::shared_ptr<RectificationMap> rectification_map_;

applications/stereo_vision/scripts/get_zed_calibration.py

+75-66
Original file line numberDiff line numberDiff line change
@@ -13,105 +13,114 @@
1313
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
16-
"""
16+
"""
1717

18-
import os
1918
import argparse
2019
import configparser
20+
import os
21+
2122
import numpy as np
22-
from scipy.spatial.transform import Rotation
2323
import yaml
24+
from scipy.spatial.transform import Rotation
2425

2526
rez = "FHD"
2627
calibration_file = "calibration.yaml"
2728

28-
parser = argparse.ArgumentParser(description='Get factory ZED calibration')
29-
required = parser.add_argument_group('required arguments')
30-
required.add_argument('-s','--serial_number', help='serial number of the ZED camera', required=True)
31-
required.add_argument('-o','--output', help='output calibration file (default: stereo_calibration.yaml)', default="stereo_calibration.yaml")
32-
required.add_argument('-r','--resoution', help='resolution setting (default: FHD)', default="FHD")
29+
parser = argparse.ArgumentParser(description="Get factory ZED calibration")
30+
required = parser.add_argument_group("required arguments")
31+
required.add_argument(
32+
"-s", "--serial_number", help="serial number of the ZED camera", required=True
33+
)
34+
required.add_argument(
35+
"-o",
36+
"--output",
37+
help="output calibration file (default: stereo_calibration.yaml)",
38+
default="stereo_calibration.yaml",
39+
)
40+
required.add_argument("-r", "--resolution", help="resolution setting (default: FHD)", default="FHD")
3341
args = parser.parse_args()
3442

35-
serial_number=args.serial_number
36-
rez = args.resoution
43+
serial_number = args.serial_number
44+
rez = args.resolution
3745
calibration_file = args.output
3846
if rez == "2K":
39-
width = 2208
40-
height = 1242
47+
width = 2208
48+
height = 1242
4149
elif rez == "FHD":
42-
width = 1920
43-
height = 1080
50+
width = 1920
51+
height = 1080
4452
elif rez == "HD":
45-
width = 1280
46-
height = 720
53+
width = 1280
54+
height = 720
4755
elif rez == "VGA":
48-
width = 672
49-
height = 376
56+
width = 672
57+
height = 376
5058
else:
51-
raise NameError("resolution not supported")
59+
raise NameError("resolution not supported")
5260

5361

54-
tmp_file = str(serial_number)+".tmp"
55-
url = "http://calib.stereolabs.com/?SN="+str(serial_number)
56-
os.system("wget -O"+ tmp_file +" "+url)
62+
tmp_file = str(serial_number) + ".tmp"
63+
url = "http://calib.stereolabs.com/?SN=" + str(serial_number)
64+
os.system("wget -O" + tmp_file + " " + url)
5765

5866
calib = configparser.ConfigParser()
5967
calib.read(tmp_file)
60-
M1 = np.zeros([3,3])
61-
M1[0,0]=calib['LEFT_CAM_'+rez]['fx']
62-
M1[0,2]=calib['LEFT_CAM_'+rez]['cx']
63-
M1[1,1]=calib['LEFT_CAM_'+rez]['fy']
64-
M1[1,2]=calib['LEFT_CAM_'+rez]['cy']
65-
M1[2,2] = 1.0
68+
M1 = np.zeros([3, 3])
69+
M1[0, 0] = calib["LEFT_CAM_" + rez]["fx"]
70+
M1[0, 2] = calib["LEFT_CAM_" + rez]["cx"]
71+
M1[1, 1] = calib["LEFT_CAM_" + rez]["fy"]
72+
M1[1, 2] = calib["LEFT_CAM_" + rez]["cy"]
73+
M1[2, 2] = 1.0
6674

6775
d1 = np.zeros(5)
68-
d1[0] = calib['LEFT_CAM_'+rez]['k1']
69-
d1[1] = calib['LEFT_CAM_'+rez]['k2']
70-
d1[2] = calib['LEFT_CAM_'+rez]['p1']
71-
d1[3] = calib['LEFT_CAM_'+rez]['p2']
72-
d1[4] = calib['LEFT_CAM_'+rez]['k3']
73-
74-
M2 = np.zeros([3,3])
75-
M2[0,0]=calib['RIGHT_CAM_'+rez]['fx']
76-
M2[0,2]=calib['RIGHT_CAM_'+rez]['cx']
77-
M2[1,1]=calib['RIGHT_CAM_'+rez]['fy']
78-
M2[1,2]=calib['RIGHT_CAM_'+rez]['cy']
79-
M2[2,2]=1.0
76+
d1[0] = calib["LEFT_CAM_" + rez]["k1"]
77+
d1[1] = calib["LEFT_CAM_" + rez]["k2"]
78+
d1[2] = calib["LEFT_CAM_" + rez]["p1"]
79+
d1[3] = calib["LEFT_CAM_" + rez]["p2"]
80+
d1[4] = calib["LEFT_CAM_" + rez]["k3"]
81+
82+
M2 = np.zeros([3, 3])
83+
M2[0, 0] = calib["RIGHT_CAM_" + rez]["fx"]
84+
M2[0, 2] = calib["RIGHT_CAM_" + rez]["cx"]
85+
M2[1, 1] = calib["RIGHT_CAM_" + rez]["fy"]
86+
M2[1, 2] = calib["RIGHT_CAM_" + rez]["cy"]
87+
M2[2, 2] = 1.0
8088

8189
d2 = np.zeros(5)
82-
d2[0] = calib['RIGHT_CAM_'+rez]['k1']
83-
d2[1] = calib['RIGHT_CAM_'+rez]['k2']
84-
d2[2] = calib['RIGHT_CAM_'+rez]['p1']
85-
d2[3] = calib['RIGHT_CAM_'+rez]['p2']
86-
d2[4] = calib['RIGHT_CAM_'+rez]['k3']
90+
d2[0] = calib["RIGHT_CAM_" + rez]["k1"]
91+
d2[1] = calib["RIGHT_CAM_" + rez]["k2"]
92+
d2[2] = calib["RIGHT_CAM_" + rez]["p1"]
93+
d2[3] = calib["RIGHT_CAM_" + rez]["p2"]
94+
d2[4] = calib["RIGHT_CAM_" + rez]["k3"]
8795

8896
t = np.zeros(3)
89-
t[0] = -float(calib['STEREO']['Baseline'])
90-
t[1] = calib['STEREO']['TY']
91-
t[2] = calib['STEREO']['TZ']
97+
t[0] = -float(calib["STEREO"]["Baseline"])
98+
t[1] = calib["STEREO"]["TY"]
99+
t[2] = calib["STEREO"]["TZ"]
92100

93101
r = np.zeros(3)
94-
r[0] = calib['STEREO']["RX_"+rez]
95-
r[1] = calib['STEREO']["CV_"+rez]
96-
r[2] = calib['STEREO']["RZ_"+rez]
102+
r[0] = calib["STEREO"]["RX_" + rez]
103+
r[1] = calib["STEREO"]["CV_" + rez]
104+
r[2] = calib["STEREO"]["RZ_" + rez]
97105
R = Rotation.from_rotvec(r).as_matrix()
98106

99-
calibration = dict(
100-
SN = serial_number,
101-
M1 = str(M1.flatten().tolist()),
102-
d1 = str(d1.tolist()),
103-
M2 = str(M2.flatten().tolist()),
104-
d2 = str(d2.tolist()),
105-
t = str(t.tolist()),
106-
R = str(R.flatten().tolist()),
107-
width = width,
108-
height = height
107+
calibration = dict(
108+
SN=serial_number,
109+
M1=str(M1.flatten().tolist()),
110+
d1=str(d1.tolist()),
111+
M2=str(M2.flatten().tolist()),
112+
d2=str(d2.tolist()),
113+
t=str(t.tolist()),
114+
R=str(R.flatten().tolist()),
115+
width=width,
116+
height=height,
109117
)
110118

111-
output_yaml = yaml.dump(calibration, default_style=None, default_flow_style=False, sort_keys=False).replace("'","")
119+
output_yaml = yaml.dump(
120+
calibration, default_style=None, default_flow_style=False, sort_keys=False
121+
).replace("'", "")
112122
print("Writing calibration to: " + calibration_file)
113-
with open(calibration_file,'w') as f:
114-
f.write(output_yaml)
115-
116-
os.system("rm "+tmp_file)
123+
with open(calibration_file, "w") as f:
124+
f.write(output_yaml)
117125

126+
os.system("rm " + tmp_file)

0 commit comments

Comments
 (0)