Python一直崩溃,并且有一个分割错误



我正试图从一堆图像创建一个全景,所以从github下载了一个repo。现在,当我运行程序,我不知道为什么,但python崩溃,我得到一个分割错误在我的终端。我目前在pycharm上运行它。我所有的图片都加载好了,然后崩溃,然后显示错误。我想从一个视频文件或一个长场景的一堆帧中创建一个全景。在这个节目中。我只想读取那个文件夹里的文件,然后开始一个接一个地拼接它们,以得到最终的图像。

错误

INFO:root:从/Users/akshayacharya/Desktop/Panorama/Raw Data/Office Data/frame030.png读取图像INFO:root:从/Users/akshayacharya/Desktop/Panorama/Raw Data/Office Data/frame024.png读取图像

zsh: segmentation fault python3 image_stitch .py——display

我也附上了我的屏幕快照供参考

#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Will Brennan'
# Built-in Modules
import os
import argparse
import logging
import cv2
import helpers
from combine import combine_images
from helpers import *
from matching import compute_matches
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
#parser.add_argument('image_paths', type=str, nargs='+', help="paths to one or more images or image directories")
parser.add_argument('-b', '--debug', dest='debug', action='store_true', help='enable debug logging')
parser.add_argument('-q', '--quiet', dest='quiet', action='store_true', help='disable all logging')
parser.add_argument('-d', '--display', dest='display', action='store_true', help="display result")
parser.add_argument('-s', '--save', dest='save', action='store_true', help="save result to file")
parser.add_argument("--save_path", dest='save_path', default="stitched.png", type=str, help="path to save result")
parser.add_argument('-k', '--knn', dest='knn', default=2, type=int, help="Knn cluster value")
parser.add_argument('-l', '--lowe', dest='lowe', default=0.7, type=float, help='acceptable distance between points')
parser.add_argument('-m', '--min', dest='min_correspondence', default=10, type=int, help='min correspondences')
args = parser.parse_args()
if args.debug:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("main")
logging.info("beginning sequential matching")
print(cv2.__version__)
#if helpers.is_cv2():
sift = cv2.SIFT()
#elif helpers.is_cv3():
#sift = cv2.xfeatures2d.SIFT_create()
#else:
#raise RuntimeError("error! unknown version of python!")
result = None
result_gry = None
flann = cv2.FlannBasedMatcher({'algorithm': 0, 'trees': 5}, {'checks': 50})
image_paths = ["/Users/akshayacharya/Desktop/Panorama/Raw Data/Office data/"]
image_index = -1
for image_path in image_paths:
#print(image_path)
if not os.path.exists(image_path):
logging.error('{0} is not a valid path'.format(image_path))
continue
if os.path.isdir(image_path):
extensions = [".jpeg", ".jpg", ".png"]
for file_path in os.listdir(image_path):
if os.path.splitext(file_path)[1].lower() in extensions:
print(file_path)
image_paths.append(os.path.join(image_path, file_path))
continue
logging.info("reading image from {0}".format(image_path))
image_colour = cv2.imread(image_path)
image_gray = cv2.cvtColor(image_colour, cv2.COLOR_RGB2GRAY)
image_index += 1
if image_index == 0:
result = image_colour
result_gry = image_gray
continue
logger.debug('computing sift features')
features0 = sift.detectAndCompute(result_gry, None)
features1 = sift.detectAndCompute(image_gray, None)
matches_src, matches_dst, n_matches = image_stitching.compute_matches(features0, features1, flann, knn=args.knn)
if n_matches < args.min_correspondence:
logger.error("error! too few correspondences")
continue
logger.debug("computing homography between accumulated and new images")
H, mask = cv2.findHomography(matches_src, matches_dst, cv2.RANSAC, 5.0)
result = combine_images(image_colour, result, H)
if args.display and not args.quiet:
helpers.display('result', result)
if cv2.waitKey(25) & 0xFF == ord('q'):
break
result_gry = cv2.cvtColor(result, cv2.COLOR_RGB2GRAY)
logger.info("processing complete!")
if args.display and not args.quiet:
cv2.destroyAllWindows()
if args.save:
logger.info("saving stitched image to {0}".format(args.save_path))
helpers.save_image(args.save_path, result)

同样的事情发生在我身上,我从Visual Studio代码中尝试过,它工作得很好。我希望你也是这样。

相关内容

最新更新