Skip to content

Commit

Permalink
change args method
Browse files Browse the repository at this point in the history
  • Loading branch information
dyfcalid committed Jun 22, 2021
1 parent 1c38a54 commit b9fb10c
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 39 deletions.
1 change: 0 additions & 1 deletion ExtrinsicCalibration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
You can edit parameters in the original file, or
args = ExCalibrator.get_args()
args.INPUT_PATH = './ExtrinsicCalibration/data/'
ExCalibrator.edit_args(args)
exCalib = ExCalibrator()
"""

28 changes: 27 additions & 1 deletion ExtrinsicCalibration/extrinsicCalib.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@
"args = parser.parse_args([])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# args.CAMERA_ID = 1 # 相机编号\n",
"# args.INPUT_PATH = './data/' # 图片、视频输入路径\n",
"# args.BORAD_WIDTH = 7 # 棋盘宽度 【内角点数】\n",
"# args.BORAD_HEIGHT = 6 # 棋盘高度 【内角点数】\n",
"# args.SOURCE_IMAGE = 'img_src' # 源图像文件名前缀\n",
"# args.DEST_IMAGE = 'img_dst' # 目标图像文件名前缀\n",
"# args.SQUARE_SIZE = 10 # 缩放后棋盘每小格边长占据图中的像素尺寸\n",
"# args.SUBPIX_REGION_SRC = 3 # 源图像亚像素优化的搜索像素范围(根据图像分辨率调整)\n",
"# args.SUBPIX_REGION_DST = 3 # 目标图像亚像素优化的搜索像素范围(根据图像分辨率调整)\n",
"# args.CENTER_FLAG = True # 是否对目标图像进行居中\n",
"# args.SCALE_FLAG = True # 是否对目标图像进行缩放\n",
"# args.STORE_FLAG = True # 是否储存目标图像(居中缩放后)\n",
"# args.STORE_PATH = './data/' # 目标图像(居中缩放后)保存路径"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -184,7 +205,12 @@
" def __init__(self):\n",
" self.src_corners_total = np.empty([0,1,2])\n",
" self.dst_corners_total = np.empty([0,1,2])\n",
" \n",
" \n",
" # 获取args参数,供外部调用修改参数\n",
" @staticmethod\n",
" def get_args():\n",
" return args\n",
" \n",
" def imgPreprocess(self, img, center, scale):\n",
" # 俯视图图像居中\n",
" if center:\n",
Expand Down
5 changes: 0 additions & 5 deletions ExtrinsicCalibration/extrinsicCalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ def __init__(self):
def get_args():
return args

@staticmethod
def edit_args(new_args):
global args
args = new_args

def imgPreprocess(self, img, center, scale):
if center:
centerImg = CenterImage()
Expand Down
1 change: 0 additions & 1 deletion IntrinsicCalibration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@
You can edit parameters in the original file, or
args = InCalibrator.get_args()
args.INPUT_PATH = './IntrinsicCalibration/data/'
InCalibrator.edit_args(args)
calibrator = InCalibrator(camera_type)
"""
5 changes: 5 additions & 0 deletions IntrinsicCalibration/intrinsicCalib.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@
" raise Exception(\"camera should be fisheye/normal\")\n",
" self.corners = []\n",
" \n",
" # 获取args参数,供外部调用修改参数\n",
" @staticmethod\n",
" def get_args():\n",
" return args\n",
" \n",
" # 获取棋盘格角点坐标\n",
" def get_corners(self, img):\n",
" ok, corners = cv2.findChessboardCorners(img, (args.BORAD_WIDTH, args.BORAD_HEIGHT),\n",
Expand Down
5 changes: 0 additions & 5 deletions IntrinsicCalibration/intrinsicCalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,6 @@ def __init__(self, camera):
def get_args():
return args

@staticmethod
def edit_args(new_args):
global args
args = new_args

def get_corners(self, img):
ok, corners = cv2.findChessboardCorners(img, (args.BORAD_WIDTH, args.BORAD_HEIGHT),
flags = cv2.CALIB_CB_ADAPTIVE_THRESH|cv2.CALIB_CB_NORMALIZE_IMAGE|cv2.CALIB_CB_FAST_CHECK)
Expand Down
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@ calibrator = InCalibrator(camera_type) # 初始化内参标定器
calib = CalibMode(calibrator, input_type, mode) # 选择标定模式
result = calib() # 开始标定
```
可以直接修改原文件中的各参数,或使用`get_args()``edit_args()`方法修改
可以直接修改原文件中的各参数,或使用`get_args()`方法获取参数并修改
```
args = InCalibrator.get_args() # 获取args参数
args.INPUT_PATH = './IntrinsicCalibration/data/'
InCalibrator.edit_args(args) # 修改args参数
args.INPUT_PATH = './IntrinsicCalibration/data/' # 修改args参数
calibrator = InCalibrator(camera_type) # 初始化内参标定器
```

Expand Down Expand Up @@ -122,11 +121,10 @@ exCalib = ExCalibrator() # 初始化外参标定器
homography = exCalib(src_raw, dst_raw) # 输入对应的两张去畸变图像 得到单应性矩阵
src_warp = exCalib.warp() # 使用warp方法得到原始图像的变换结果
```
可以直接修改原文件中的各参数,或使用`get_args()``edit_args()`方法修改
可以直接修改原文件中的各参数,或使用`get_args()`方法获取参数并修改
```
args = ExCalibrator.get_args() # 获取args参数
args.INPUT_PATH = './ExtrinsicCalibration/data/'
ExCalibrator.edit_args(args) # 修改args参数
args.INPUT_PATH = './ExtrinsicCalibration/data/' # 修改args参数
exCalib = ExCalibrator() # 初始化外参标定器
```

Expand Down Expand Up @@ -158,12 +156,11 @@ surround = bev(front,back,left,right) # 输入前后左右四张
bev = BevGenerator(blend=True, balance=True) # 使用图像融合以及平衡
surround = bev(front,back,left,right,car) # 可以加入车辆图片
```
可以直接修改原文件中的各参数,或使用`get_args()``edit_args()`方法修改
可以直接修改原文件中的各参数,或使用`get_args()`方法获取参数并修改
```
args = BevGenerator.get_args() # 获取环视鸟瞰args参数
args.CAR_WIDTH = 200
args.CAR_HEIGHT = 350
BevGenerator.edit_args(args) # 修改为新的参数
args.CAR_HEIGHT = 350 # 修改为新的参数
bev = BevGenerator() # 初始化环视鸟瞰生成器
```

Expand Down
1 change: 0 additions & 1 deletion SurroundBirdEyeView/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
args = BevGenerator.get_args()
args.CAR_WIDTH = 200
args.CAR_HEIGHT = 350
BevGenerator.edit_args(args)
bev = BevGenerator()
"""
8 changes: 1 addition & 7 deletions SurroundBirdEyeView/surroundBEV.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -402,16 +402,10 @@
" self.masks = [BlendMask('front'), BlendMask('back'), \n",
" BlendMask('left'), BlendMask('right')]\n",
" \n",
" # 获取args参数,供外部调用\n",
" # 获取args参数,供外部调用修改参数\n",
" @staticmethod\n",
" def get_args():\n",
" return args\n",
" \n",
" # 修改args参数,供外部调用\n",
" @staticmethod\n",
" def edit_args(new_args):\n",
" global args\n",
" args = new_args\n",
" \n",
" # 重新赋值args参数\n",
" def init_args(self):\n",
Expand Down
5 changes: 0 additions & 5 deletions SurroundBirdEyeView/surroundBEV.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,6 @@ def __init__(self, blend=args.BLEND_FLAG, balance=args.BALANCE_FLAG):
def get_args():
return args

@staticmethod
def edit_args(new_args):
global args
args = new_args

def init_args(self):
global FRAME_WIDTH, FRAME_HEIGHT, BEV_WIDTH, BEV_HEIGHT
global CAR_WIDTH, CAR_HEIGHT, FOCAL_SCALE, SIZE_SCALE
Expand Down
6 changes: 2 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def runInCalib_1():
def runInCalib_2():
print("Intrinsic Calibration ......")
args = InCalibrator.get_args() # 获取内参标定args参数
args.INPUT_PATH = './IntrinsicCalibration/data/'
InCalibrator.edit_args(args) # 修改为新的参数
args.INPUT_PATH = './IntrinsicCalibration/data/' # 修改为新的参数
calibrator = InCalibrator('fisheye') # 初始化内参标定器
calib = CalibMode(calibrator, 'image', 'auto') # 选择标定模式
result = calib() # 开始标定
Expand Down Expand Up @@ -79,8 +78,7 @@ def runBEV():

args = BevGenerator.get_args() # 获取环视鸟瞰args参数
args.CAR_WIDTH = 200
args.CAR_HEIGHT = 350
BevGenerator.edit_args(args) # 修改为新的参数
args.CAR_HEIGHT = 350 # 修改为新的参数

bev = BevGenerator(blend=True, balance=True) # 初始化环视鸟瞰图生成器
surround = bev(front, back, left, right) # 输入前后左右四张原始相机图像 得到拼接后的鸟瞰图
Expand Down

0 comments on commit b9fb10c

Please sign in to comment.