We are unable to perform rubber band on image which is rotated on validation stage. Is there any way we can save the data of OCR index field before rotating the image and the rotate then image manually. Once the image is rotated all the Index field becomes invalid and user cannot perform rubber band also on the same image. After rotating the image we moved the same batch to KTM server and back to KTM validation still the Rubber band is not possible
1 Answers
There isn't a clear easy answer to this, but I can suggest some options. First few clarifications. Even if you already know these, it will help the question make more sense to others:
- Although Kofax Capture actually does a zonal OCR read on-demand when you lasso a section of the image, Kofax Transformation Modules actually just returns words within the coordinates of the OCR that has already performed during KTM Server.
- Out of the box, KTM Validation only has the ability to do "permanent" rotation, in the sense that it isn't simply rotating what you see at the moment, but persisting the rotation either in the image on disk or in metadata (depending on project settings).
- The implication of rotation is that the stored OCR is no longer valid for the new orientation, thus it gets removed. Any fields which have word objects (which are tied to the OCR) are removed and invalidated.
- KTM Server has already marked the batch as processed, so it won't try again.
Preserve field results during rotation
I believe if you remove the word objects from a field then it won't clear it on rotation. You may need to also unset the page index so it isn't connected to the page being rotated.
Dim FieldIndex as Integer
For FieldIndex=0 to pXDoc.Fields.Count-1
While pXDoc.Fields.ItemByIndex(FieldIndex).Words.Count>0
pXDoc.Fields.ItemByIndex(FieldIndex).Words.Remove(0)
Wend
pXDoc.Fields.ItemByIndex(FieldIndex).PageIndex=-1
Next
If there are any issues with this, you can also take other approaches to storing and restoring the values in the Batch_BeforeRotateImage and Batch_AfterRotateImage events.
Rubberband OCR (Lassoing Words) After Rotation
There is no clear simple way to do this. I considered suggesting calling OCR from script after rotation, but aside from being a gray area of whether the relevant objects are supported, trying that shows that the OCR components don't even get loaded into validation.
A Different Direction: Rotating Only The Display Image
I mentioned earlier that out of the box KTM Validation cannot just do a temporary rotation, however, if you don't need the rotation to persist, you can accomplish this in script. Use this function:
Public Sub RotateCurrentValidationImage(pXDoc As CscXDocument, ValForm As CscScriptValidationForm, Optional RotateCounterClockwise As Boolean=False)
Dim Img As CscImage
Set Img=pXDoc.CDoc.Pages(ValForm.CurrentPageIndex).GetImage()
Img.RotateImage(IIf(RotateCounterClockwise,CscImgRotation90Left,CscImgRotation90Right))
pXDoc.CDoc.Pages(ValForm.CurrentPageIndex).SetImage(Img)
ValForm.DocViewer.DisplayPage(-1)
ValForm.DocViewer.DisplayPage(ValForm.CurrentPageIndex)
End Sub
From a Button Click event like so:
Private Sub ValidationForm_ButtonClicked(ByVal ButtonName As String, ByVal pXDoc As CASCADELib.CscXDocument)
Select Case ButtonName
Case "RotateDisplayImage"
RotateCurrentValidationImage(pXDoc,ValidationForm)
End Select
End Sub
This only rotates the currently displayed image in memory. It does not affect the existing OCR (it will still exist, however it also cannot be rotated to match the coordinates of the image), nor does it affect the existing fields, nor will the rotation persist once the batch is closed.
In this situation rubberband OCR technically works, however words and the image won't line up, so it won't be useful while rotated. This might help if you need to rotate to manually key something, but rubberband OCR will only be useful when returned to the original orientation.

- 1,374
- 15
- 24
-
Thanks Stephen for your inputs was very much help full. I Need one more help from you as you know OCR automatically performs the rotation on the image I want to OCR to perform a conditional rotation on the image based on the source of the image. I want the image should rotate automatically when the source is Email and to and it should not allow rotation when the source is Folder import – Manish Sharma Sep 26 '14 at 11:21
-
Glad it was helpful. Try to avoid asking new questions in the comments. I see that you've asked the question separately which is good: http://stackoverflow.com/questions/26058703/conditional-ocr-rotation-on-the-image-or-page-in-kofax I've spent a fair bit of effort answering two of your questions however I'm reluctant to look into another if you are not marking answers as accepted. – Stephen Klancher Sep 30 '14 at 00:51
-
Hi @Stephen i have accepted your answers. I appreciate your valuable inputs was very much helpful. To add up to the resolution for issue we moved image to back to scan queue and then KTM server we were able to perform rubber band on the image after rotating image in Scan queue. – Manish Sharma Sep 30 '14 at 07:20
-
For the Above issue Kofax suggested the Below script. This script would work when user will rotate the image and change the doc type to ReOCR after that batche moves to KTM server queue and the Val and then it allows rubber band on the image but this is not working for me please suggest if you have any idea – Manish Sharma Oct 17 '14 at 08:58
-
Private Sub Batch_Close(ByVal pXRootFolder As CASCADELib.CscXFolder, ByVal CloseMode As CASCADELib.CscBatchCloseMode) If Project.ScriptExecutionMode = CASCADELib.CscScriptModeValidation And CloseMode = CASCADELib.CscBatchCloseFinal Then Dim i As Integer Dim bReject As Boolean bReject = False – Manish Sharma Oct 17 '14 at 09:00
-
For i = 0 To pXRootFolder.DocInfos.Count - 1 Dim pXDoc As CscXDocInfo Set pXDoc = pXRootFolder.DocInfos(i) If pXDoc.ExtractionClass <> "OrderForm" Then 'determine If the Document Is rejected bReject = True End If Next If bReject Then pXRootFolder.XValues.Set("KTM_DOCUMENTROUTING_QUEUE_THISBATCH", "KTM.Server") End If End If End Sub – Manish Sharma Oct 17 '14 at 09:01