Skip to main content

Hi,

Can any one advise how to convert the following VB code to Cobol pls.

Its for a fingerpint reader.

Imports System.Threading
Imports System.IO
Imports DPUruNet
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Text


Public Class Verify
Private _readers As ReaderCollection
Private _reader As Reader
Private _readerResult As Constants.ResultCode
Private FmdToVerify As List(Of Fmd) = New List(Of Fmd)
Private reset As Boolean = False
Private nThread As Thread
Private enrolledFmdStr As String
Public strsplit() As String
Public callsw As String
Public callsw1 As String
Public callOutputFileName As String

Private Function CaptureAndExtractFMD() As String


Dim capResult As CaptureResult
Dim vResult As IdentifyResult = Nothing

While Not reset

Dim result As Constants.ResultCode = _reader.GetStatus()
If _reader.Status.Status = Constants.ReaderStatuses.DP_STATUS_BUSY Then
Thread.Sleep(50)
Continue While
End If

If _reader.Status.Status = Constants.ReaderStatuses.DP_STATUS_READY Then

capResult = _reader.Capture(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, 5000, _reader.Capabilities.Resolutions(0))
If capResult.Quality = Constants.CaptureQuality.DP_QUALITY_GOOD Then

Dim count As Integer
Dim str As String
For count = 0 To 20
Try
str = strsplit(count).Trim(" ")
Catch ex As Exception
str = ""
End Try

If Not str = "" Then
Dim fs As FileStream = File.OpenRead(str)
Dim sr As StreamReader = New StreamReader(fs)
FmdToVerify.Clear()
FmdToVerify.Add(Fmd.DeserializeXml(sr.ReadLine().ToString()))
sr.Close()

Dim result3 As DataResult(Of Fmd) = FeatureExtraction.CreateFmdFromFid(capResult.Data, Constants.Formats.Fmd.DP_VERIFICATION)
If result3.ResultCode <> Constants.ResultCode.DP_SUCCESS Then
SendMessage("Could not successfully create Fmd")
Else
vResult = Comparison.Identify(result3.Data, 0, getFmdToVerify, 21474, 5)
If vResult.ResultCode = Constants.ResultCode.DP_SUCCESS Then
If vResult.Indexes.Length > 0 Then
SendMessage("User Authorized!")
callsw1 = str
callsw = "EXIT"
'btnMatchFound.Visible = True

Exit Function
Else
SendMessage("User Unauthorized!")
End If

Else
SendMessage("Error occured on verification")
End If
Dim FPBitmap As Bitmap = CreateBitmap(capResult.Data.Views(0).RawImage, capResult.Data.Views(0).Width, capResult.Data.Views(0).Height)
VerifyPictureBox.Image = New Bitmap(FPBitmap)
End If
End If
Next
End If
End If

End While

End Function

Hi,

Can any one advise how to convert the following VB code to Cobol pls.

Its for a fingerpint reader.

Imports System.Threading
Imports System.IO
Imports DPUruNet
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Text


Public Class Verify
Private _readers As ReaderCollection
Private _reader As Reader
Private _readerResult As Constants.ResultCode
Private FmdToVerify As List(Of Fmd) = New List(Of Fmd)
Private reset As Boolean = False
Private nThread As Thread
Private enrolledFmdStr As String
Public strsplit() As String
Public callsw As String
Public callsw1 As String
Public callOutputFileName As String

Private Function CaptureAndExtractFMD() As String


Dim capResult As CaptureResult
Dim vResult As IdentifyResult = Nothing

While Not reset

Dim result As Constants.ResultCode = _reader.GetStatus()
If _reader.Status.Status = Constants.ReaderStatuses.DP_STATUS_BUSY Then
Thread.Sleep(50)
Continue While
End If

If _reader.Status.Status = Constants.ReaderStatuses.DP_STATUS_READY Then

capResult = _reader.Capture(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, 5000, _reader.Capabilities.Resolutions(0))
If capResult.Quality = Constants.CaptureQuality.DP_QUALITY_GOOD Then

Dim count As Integer
Dim str As String
For count = 0 To 20
Try
str = strsplit(count).Trim(" ")
Catch ex As Exception
str = ""
End Try

If Not str = "" Then
Dim fs As FileStream = File.OpenRead(str)
Dim sr As StreamReader = New StreamReader(fs)
FmdToVerify.Clear()
FmdToVerify.Add(Fmd.DeserializeXml(sr.ReadLine().ToString()))
sr.Close()

Dim result3 As DataResult(Of Fmd) = FeatureExtraction.CreateFmdFromFid(capResult.Data, Constants.Formats.Fmd.DP_VERIFICATION)
If result3.ResultCode <> Constants.ResultCode.DP_SUCCESS Then
SendMessage("Could not successfully create Fmd")
Else
vResult = Comparison.Identify(result3.Data, 0, getFmdToVerify, 21474, 5)
If vResult.ResultCode = Constants.ResultCode.DP_SUCCESS Then
If vResult.Indexes.Length > 0 Then
SendMessage("User Authorized!")
callsw1 = str
callsw = "EXIT"
'btnMatchFound.Visible = True

Exit Function
Else
SendMessage("User Unauthorized!")
End If

Else
SendMessage("Error occured on verification")
End If
Dim FPBitmap As Bitmap = CreateBitmap(capResult.Data.Views(0).RawImage, capResult.Data.Views(0).Width, capResult.Data.Views(0).Height)
VerifyPictureBox.Image = New Bitmap(FPBitmap)
End If
End If
Next
End If
End If

End While

End Function

The following is about as close as I can come to a COBOL conversion without actually having the DPUruNet class available to me:
I am sure there are some mistakes but it is a starting point for you anyway...

 

      $set ilusing"System.Threading"
      $set ilusing"System.IO"
      $set ilusing"DPUruNet"
      $set ilusing"System.Drawing"
      $set ilusing"System.Drawing.Imaging"
      $set ilusing"System.Text"
             
       class-id Verify.Verify.
       
       working-storage section.
       01 _readers type ReaderCollection.
       01 _reader type Reader.
       01 _readerResult type Constants.ResultCode.
       01 FmdToVerify type List[Fmd] value New List[Fmd].
       01 fReset condition-value value false.
       01 nThread type Thread.
       01 enrolledFmdStr string.
       *>01 strsplit() As String
       01 callsw string property.
       01 callsw1 string property.
       01 callOutputFileName string property.
       
       method-id CaptureAndExtractFMD.
       local-storage section.
       01 capResult type CaptureResult.
       01 vResult type IdentifyResult value "".
       procedure division returning mystring as string.
           perform until Freset
              declare result as type Constants::ResultCode = _reader::GetStatus()
              if _reader::Status::Status = type Constants::ReaderStatuses::DP_STATUS_BUSY
                 invoke type Thread::Sleep(50)
                 exit perform cycle
              end-if
              if _reader::Status::Status = type Constants::ReaderStatuses::DP_STATUS_READY 
                 set capResult to _reader::Capture(type Constants::Formats::Fid::ANSI, type Constants::CaptureProcessing::DP_IMG_PROC_DEFAULT, 5000, type _reader::Capabilities::Resolutions(0))
                 if capResult::Quality = type Constants::CaptureQuality::DP_QUALITY_GOOD 
                    declare mycount as binary-long
                    declare str as string
                    perform varying mycount from 0 by 1 until mycount = 20
                       try
                          set str to type strsplit(mycount)::Trim(" ")
                       catch ex as type Exception
                          set str to ""
                       end-try
                       if not str = "" 
                          declare fs as type FileStream = type File::OpenRead(str)
                          declare sr as type StreamReader = New StreamReader(fs)
                          invoke FmdToVerify::Clear()
                          invoke FmdToVerify::Add(Fmd::DeserializeXml(sr::ReadLine()::ToString()))
                          invoke sr::Close()
                          declare result3 as type DataResult[Fmd] = type FeatureExtraction::CreateFmdFromFid(capResult::Data, type Constants::Formats::Fmd::DP_VERIFICATION)
                          if result3::ResultCode <> type Constants::ResultCode::DP_SUCCESS
                             invoke type SendMessage("Could not successfully create Fmd")
                          else
                             set vResult to type Comparison::Identify(result3::Data, 0, type getFmdToVerify, 21474, 5)
                             if vResult::ResultCode = type Constants::ResultCode::DP_SUCCESS
                                if vResult::Indexes::Length > 0 
                                   invoke type SendMessage("User Authorized!")
                                   set callsw1 to str
                                   set callsw to "EXIT"
                                   *>'btnMatchFound.Visible = True
                                   exit method
                               else
                                   invoke type SendMessage("User Unauthorized!")
                               end-if
                             else
                                 invoke type SendMessage("Error occured on verification")
                             end-if
                             declare FPBitmap as type Bitmap = CreateBitmap(capResult::Data::Views(0)::RawImage, capResult::Data::Views(0)::Width, capResult::Data::Views(0)::Height)
                             set VerifyPictureBox::Image to new Bitmap(FPBitmap)
                          end-if
                       end-if
                    end-perform
                 end-if
              end-if
           end-perform


           goback.
       end method.

       end class.

Hi,

Can any one advise how to convert the following VB code to Cobol pls.

Its for a fingerpint reader.

Imports System.Threading
Imports System.IO
Imports DPUruNet
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Text


Public Class Verify
Private _readers As ReaderCollection
Private _reader As Reader
Private _readerResult As Constants.ResultCode
Private FmdToVerify As List(Of Fmd) = New List(Of Fmd)
Private reset As Boolean = False
Private nThread As Thread
Private enrolledFmdStr As String
Public strsplit() As String
Public callsw As String
Public callsw1 As String
Public callOutputFileName As String

Private Function CaptureAndExtractFMD() As String


Dim capResult As CaptureResult
Dim vResult As IdentifyResult = Nothing

While Not reset

Dim result As Constants.ResultCode = _reader.GetStatus()
If _reader.Status.Status = Constants.ReaderStatuses.DP_STATUS_BUSY Then
Thread.Sleep(50)
Continue While
End If

If _reader.Status.Status = Constants.ReaderStatuses.DP_STATUS_READY Then

capResult = _reader.Capture(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, 5000, _reader.Capabilities.Resolutions(0))
If capResult.Quality = Constants.CaptureQuality.DP_QUALITY_GOOD Then

Dim count As Integer
Dim str As String
For count = 0 To 20
Try
str = strsplit(count).Trim(" ")
Catch ex As Exception
str = ""
End Try

If Not str = "" Then
Dim fs As FileStream = File.OpenRead(str)
Dim sr As StreamReader = New StreamReader(fs)
FmdToVerify.Clear()
FmdToVerify.Add(Fmd.DeserializeXml(sr.ReadLine().ToString()))
sr.Close()

Dim result3 As DataResult(Of Fmd) = FeatureExtraction.CreateFmdFromFid(capResult.Data, Constants.Formats.Fmd.DP_VERIFICATION)
If result3.ResultCode <> Constants.ResultCode.DP_SUCCESS Then
SendMessage("Could not successfully create Fmd")
Else
vResult = Comparison.Identify(result3.Data, 0, getFmdToVerify, 21474, 5)
If vResult.ResultCode = Constants.ResultCode.DP_SUCCESS Then
If vResult.Indexes.Length > 0 Then
SendMessage("User Authorized!")
callsw1 = str
callsw = "EXIT"
'btnMatchFound.Visible = True

Exit Function
Else
SendMessage("User Unauthorized!")
End If

Else
SendMessage("Error occured on verification")
End If
Dim FPBitmap As Bitmap = CreateBitmap(capResult.Data.Views(0).RawImage, capResult.Data.Views(0).Width, capResult.Data.Views(0).Height)
VerifyPictureBox.Image = New Bitmap(FPBitmap)
End If
End If
Next
End If
End If

End While

End Function

Hi Chris, thanks and I can tell you were pretty dang close.

Neil and I worked through this together and got this converted and running successfully - a COBOL application processing a fingerprint reader and displaying the thumb print on the screen.

Most things were converted easily enough but there were a couple of areas that involved new syntax or new .NET technology Neil wasn't familiar with.

We agreed that some webinars on OO COBOL and .NET./JVM would help - I'll post a question on the forum to see who else might like to see those.