Halcon机器视觉论坛

 找回密码
 会员注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 371|回复: 2
收起左侧

[问题咨询] VP怎么实现图像拼接

[复制链接]

该用户从未签到

2

主题

4

帖子

90

积分

Rank: 1

积分
90
发表于 2019-3-21 13:08:09 | 显示全部楼层 |阅读模式

试用员工 |主题 2|帖子 4|积分 90

51Halcon诚邀您的加入,专注于机器视觉开发与应用技术,我们一直都在努力!

您需要 登录 才可以下载或查看,没有帐号?会员注册

x
用的是哪个工具

大体流程设置是什么样的

发帖求助前要善用论坛搜索功能,那里可能会有你要找的答案;

如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题前面加上【已解决】

回报帮助你解决问题的坛友,右下角【免费评分】赠与对方视觉币和热心值,伸手党遭人唾弃,做一个热心并受欢迎的人!

  • TA的每日心情
    叹气
    2019-3-30 14:50
  • 签到天数: 5 天

    连续签到: 1 天

    [LV.2]偶尔看看I

    1

    主题

    16

    帖子

    490

    积分

    Rank: 2Rank: 2

    积分
    490
    发表于 2019-3-21 21:59:57 | 显示全部楼层

    正式员工 |主题 1|帖子 16|积分 490

    用脚本可以实现
    Imports System
    Imports System.Threading
    Imports System.Windows.Forms
    Imports Cognex.VisionPro
    Imports Cognex.VisionPro.QuickBuild
    Imports Cognex.VisionPro.ImageProcessing

    Public Class UserScript
      Inherits CogJobBaseScript

      ' A CogCopyRegionTool is used to stitch images and hold the intermediate result.
      Dim imageStitcher As CogCopyRegionTool
      
      ' A counter of the number of sub-images acquired.  This is used to control the
      ' image stitching and determine when the final image is finished.
      Dim counter As Integer
      
      ' Helper function which resets our internal variables so that the next acquired
      ' image will restart the stitching process.
      Private Sub ResetImage
        imageStitcher = Nothing
        counter = 0
      End Sub
      
      ' Called immediately after an acquisition has completed.
      ' Return true if the image should be inspected.
      ' Return false to skip the inspection and acquire another image.
      Overrides Function PostAcquisitionRef(ByRef image As Cognex.VisionPro.ICogImage) As Boolean
        counter = counter + 1
       
        ' First sub-image has been acquired
        If Counter = 1
          ' Create a new tool
          imageStitcher = new CogCopyRegionTool()

          ' Create a destination image and assign it to the tool
          Dim stitchedImage As CogImage8Grey = new CogImage8Grey()
          stitchedImage.Allocate(image.Width*2, image.Height*2)
          imageStitcher.DestinationImage = stitchedImage
          
          imageStitcher.Region = Nothing
          imageStitcher.RunParams.ImageAlignmentEnabled = true
          
          ' First sub-image goes into the upper left corner
          imageStitcher.RunParams.DestinationImageAlignmentX = 0
          imageStitcher.RunParams.DestinationImageAlignmentY = 0
          
        Else If Counter = 2
          ' Second sub-image goes into the upper right corner
          imageStitcher.RunParams.DestinationImageAlignmentX = image.Width
          imageStitcher.RunParams.DestinationImageAlignmentY = 0
          
        Else If Counter = 3
          ' Third sub-image goes into the lower left corner
          imageStitcher.RunParams.DestinationImageAlignmentX = 0
          imageStitcher.RunParams.DestinationImageAlignmentY = image.Height

        Else
          ' Final sub-image  goes into the lower right corner
          imageStitcher.RunParams.DestinationImageAlignmentX = image.Width
          imageStitcher.RunParams.DestinationImageAlignmentY = image.Height
        End If

        ' Run the tool to add the just-acquired sub-image
        imageStitcher.InputImage = CType(image, CogImage8Grey)
        imageStitcher.Run()
       
        ' If this was the last portion of the image
        If Counter = 4
          ' Set the acquired image to the final stitched image
          image = imageStitcher.OutputImage
          
          ' Reset to begin a new stitched image next time
          ResetImage()
          
          ' Return true to inspect the stitched image
          Return True

        Else  
          ' Return false to skip inspection and acquire the next sub-image
          Return False
        End If
      End Function

    #Region "When the Script is Initialized"
      'Perform any initialization required by your script here
      Overrides Sub Initialize(ByVal jobParam As CogJob)
        'DO NOT REMOVE - Call the base class implementation first - DO NOT REMOVE
        MyBase.Initialize(jobParam)
       
        ResetImage()
       
        'Display an informational message box explaining the sample.  Note that this
        'is done from a separate thread so that you can still interact with QuickBuild
        'while viewing the message box.
        Dim msgThread As Thread
        msgThread = new System.Threading.Thread(new ThreadStart(addressof showMsg))
        msgThread.Start()
      End Sub
      
      'A helper subroutine to display the informational message box.  This subroutine
      'is run in a separate thread.
      <MTAThread()> Sub showMsg()
        Dim msgText as String
        msgText  = "This sample uses script to combine 4 acquired images into a single large" + Environment.NewLine
        msgText += "image for inspection."
        msgText += Environment.NewLine + Environment.NewLine
        msgText += "To view the script:" + Environment.NewLine
        msgText += "  1) Select Configure, Job Properties... from the Job Editor menu" + Environment.NewLine
        msgText += "  2) Click the Edit Job Script button" + Environment.NewLine
        MessageBox.Show(msgText, "Image Stitching Script Sample")
      End Sub

    #End Region

    End Class


    自带的例程里有

    发帖求助前要善用论坛搜索功能,那里可能会有你要找的答案;

    如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题前面加上【已解决】

    回报帮助你解决问题的坛友,右下角【免费评分】赠与对方视觉币和热心值,伸手党遭人唾弃,做一个热心并受欢迎的人!

    该用户从未签到

    2

    主题

    4

    帖子

    90

    积分

    Rank: 1

    积分
    90
     楼主| 发表于 2019-4-21 16:46:55 | 显示全部楼层

    试用员工 |主题 2|帖子 4|积分 90

    gax125 发表于 2019-3-21 21:59
    用脚本可以实现
    Imports System
    Imports System.Threading

    这个只是组合图像。。。有没有无缝拼接的。。。。就是图像有重合的地方自动拼接重叠的

    发帖求助前要善用论坛搜索功能,那里可能会有你要找的答案;

    如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题前面加上【已解决】

    回报帮助你解决问题的坛友,右下角【免费评分】赠与对方视觉币和热心值,伸手党遭人唾弃,做一个热心并受欢迎的人!

    您需要登录后才可以回帖 会员登录 | 会员注册

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    Halcon鸟叔机器视觉1鸟叔机器视觉 | 51Halcon官方客服咨询官方客服咨询 | Halcon切换助手使用反馈切换助手使用反馈 | 51Halcon论坛管理团队论坛管理团队

    申请友链| 小黑屋| 手机版| Archiver| Halcon机器视觉论坛  

    粤ICP备15095995号-2 粤公网安备44030602000670号

    Powered by Discuz! X3.4 Licensed© 2015-2019 Comsenz Inc.

    快速回复 返回顶部 返回列表