怎么在python中使用OpenCV拼接图像

  介绍

本篇文章为大家展示了怎么在python中使用OpenCV拼接图像,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

得到__future__  import  print_function   import  cv2  as 简历   import  numpy  as  np   import  argparse   import 系统      modes =, (cv.Stitcher_PANORAMA, cv.Stitcher_SCANS)      parser =, argparse.ArgumentParser(描述=& # 39;Stitching 示例# 39;公司)   parser.add_argument(& # 39;——模式# 39;=,type , int,, choices =,模式,,default =, cv.Stitcher_PANORAMA,=,help  & # 39; Determines  configuration  of 订书机只,default  is “全景”,(% d), & # 39;   ,,& # 39;mode  suitable  for  creating  photo 全景记录只Option “扫描”,(% d), is  suitable  & # 39;   ,,& # 39;for  stitching  materials  under  affine 转换,,such  as 扫描强生# 39;,%,模式)   parser.add_argument(& # 39;——输出# 39;,,default =, & # 39; result.jpg& # 39;,=,help  & # 39; Resulting 图像只,default  is “result.jpg”# 39;公司)   parser.add_argument (& # 39; img # 39;,,娜戈=& # 39;+ & # 39;,,help =, & # 39; input 图像# 39;)   时间=args  parser.parse_args ()      #,read  input 图像   时间=imgs  []   for  img_name  args.img拷贝:=,,img  cv.imread (img_name)   ,if  img  is 没有:   打印才能(“停下来# 39;t  read  image “, +, img_name)   sys.exit才能(1)   ,imgs.append (img)      时间=stitcher  cv.Stitcher.create (args.mode)   状态,pano =, stitcher.stitch(一)      if  status  !=, cv.Stitcher_OK:   ,打印(“停下来# 39;t  stitch 图像,error  code =, % d", %,状态)   ,sys.exit (1)      cv.imwrite (args.output,帕诺人);   print (“stitching  completed 成功只% s 得救了!“,%,args.output)

上面写了一大堆,然鹅,直接拿来用的话,用下面的代码可以了,简单粗暴

import  numpy  as  np   import  cv2   得到cv2  import 订书机      if  __name__ ==,“__main__":=,,img1  cv2.imread (& # 39; 1. jpg # 39;)=,,img2  cv2.imread (& # 39; 2. jpg # 39;)=,,stitcher  cv2.createStitcher(假)   ,# stitcher =, cv2.Stitcher.create (cv2.Stitcher_PANORAMA),根据不同的OpenCV版本来调用   ,(_result,帕诺人),=,stitcher.stitch ((img1, img2))   ,cv2.imshow(& # 39;帕诺人# 39;,帕诺人)   之前,cv2.waitKey (0)

上述内容就是怎么在python中使用OpenCV拼接图像,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。

怎么在python中使用OpenCV拼接图像