Author |
Topic  |
|
mazluta

Israel
12 Posts |
Posted - May 19 2025 : 07:07:23
|
i have Delphi UniGui DMS Application (Document Management System). first part is browser desktop and the second is web mobile application. in the web mobile app i give the user the option to take "picture" using camera device. so - let say i have 5 images ("pictures" by mobile camera device). now - i want to convert them to 1 pdf file as DOCUMENT. to create pdf from those 5 images there is no problem. what i want is convert the images to document page "like" it scanned using scanner. like CamScan Dose.
can i do it with the ImageEn Components or Envision?
Yossi Mazal-Tov |
|
xequte
    
39020 Posts |
|
mazluta

Israel
12 Posts |
Posted - May 19 2025 : 16:27:39
|
first thanks. no, i mean to : "Straighten" the image and turn it into an A4 page "Document". from then i will join al the images in the package and make them "one" pdf document. there is application in mobile -CamScanner - they do it. as it should.
Yossi Mazal-Tov |
 |
|
mazluta

Israel
12 Posts |
Posted - May 19 2025 : 16:45:56
|
i asked "Gemini" (he is my closest friend now).
You're looking to implement document straightening and conversion to a standard A4 document size from images captured with a mobile UniGUI application, similar to CamScanner. You then want to combine these processed images into a single PDF.
Here's a breakdown of how you might approach this using Delphi components, primarily focusing on ImageEn (as it's a powerful imaging library):
1. Capturing Images (Your Current Code)
Your existing UniGUI mobile application already handles capturing images from the camera and displaying them. You're saving these as PNG or JPG files in the server's local cache. This part seems to be working correctly.
2. Image Straightening (Perspective Correction)
This is the core of the "CamScanner" effect. You need to perform a perspective transformation to correct for the camera's angle when the photo was taken.
Detecting Document Edges: The first step is to identify the four corners of the document in the image. This can be done using various image processing techniques: Edge Detection: Algorithms like Canny edge detection can highlight the edges in the image. Hough Transform: Can be used to detect lines, which might form the document's boundaries. Blob Analysis: Identifying rectangular or near-rectangular shapes. Finding the Corners: Once edges or shapes are detected, you'll need to find the four corner points that define the document. This might involve analyzing intersections of lines or the vertices of detected shapes. Perspective Transformation: Once you have the four corner points of the document in the original image, and you know the desired output dimensions (A4 ratio), you can calculate a perspective transformation matrix. This matrix can then be used to warp the original image so that the detected document becomes a rectangular A4-sized image. Using ImageEn for Straightening:
ImageEn has powerful functions that can help with this:
EIJEdgeDetect: For edge detection. EIHHoughLines: For detecting lines. IEPerspective: Performs perspective transformations. You would need to provide the source corner points and the destination corner points (forming an A4 ratio rectangle). You would likely need to implement a process like this:
Load the captured image into an TIEBitmap. Use edge detection and possibly line detection to find the boundaries of the document. Implement logic to identify the four corner points of the document from the detected features. This might be the most complex part and could involve some custom algorithms. Define the target A4 rectangle's corners. Use IEPerspective with the source and target corners to straighten the image. 3. Converting to A4 "Document" Size
After straightening, you'll want to ensure the image has the aspect ratio of an A4 page. You might need to:
Scale: Resize the straightened image to have the approximate proportions of A4. Add White Borders: If the straightened document doesn't perfectly fit the A4 ratio, you could add white borders to make it conform. ImageEn's resizing capabilities (IEScale, IEResize) would be useful here.
4. Combining Images into a Single PDF
Once you have processed each captured image into a straightened, A4-like "document" image, you can combine them into a single PDF file.
Using ImageEn for PDF Creation:
ImageEn provides classes for PDF creation:
TIEPDFDocument: Allows you to create and manipulate PDF documents. You can add each processed TIEBitmap as a new page to the PDF document using methods of TIEPDFDocument. Example Workflow:
User captures one or more images using your UniGUI mobile app. The images are saved on the server. For each image: a. Load the image into a TIEBitmap. b. Implement your document edge detection and corner finding logic. c. Define the target A4 rectangle corners. d. Use IEPerspective to straighten the image. e. Resize or add borders to make it A4 ratio. Create a TIEPDFDocument. Add each processed TIEBitmap as a new page to the TIEPDFDocument. Save the TIEPDFDocument to a file, which can then be downloaded by the user. Other Components:
While ImageEn is a strong contender, other Delphi imaging libraries like Graphics32 or custom image processing routines could also be used, but ImageEn likely offers the most convenient set of tools for this task.
Challenges:
Robust Corner Detection: Accurately and reliably detecting the corners of the document in various lighting conditions and with different backgrounds can be challenging. This might require experimentation with different image processing techniques and parameter tuning. Performance: Image processing can be CPU-intensive. For mobile applications, you'll need to consider the performance on the server if you're doing the processing there. To help you further, could you clarify:
Do you already have ImageEn or Envision components in your project? Are you looking for specific code examples for certain steps (like perspective transform with ImageEn)?
Let me know how you'd like to proceed!
some times he lie so we start with the flow and see what will be - Ca Sera Sera
if you have something. please advise.
Yossi Mazal-Tov |
 |
|
xequte
    
39020 Posts |
Posted - May 19 2025 : 17:19:17
|
Sorry, I'm not really understanding your requirement. Please attach some examples.
Nigel Xequte Software www.imageen.com
|
 |
|
mazluta

Israel
12 Posts |
Posted - May 19 2025 : 18:32:15
|



the user take a picture of page 1 and then page 2
i want to take those "images" (page 1 + page 2), "align" them, turn them into A4 pages, and then create a PDF file from them that will contain 2 pages.
Yossi Mazal-Tov |
 |
|
mazluta

Israel
12 Posts |
|
xequte
    
39020 Posts |
|
mazluta

Israel
12 Posts |
Posted - May 20 2025 : 05:05:58
|
no problem to create the pdf. the problem is the "To straighten" the image that was taken from the "camera" so it will like "document" and not like "picture"
is this the way to "stainghten" the "image" :
ImageEn has powerful functions that can help with this:
EIJEdgeDetect: For edge detection. EIHHoughLines: For detecting lines. IEPerspective: Performs perspective transformations. You would need to provide the source corner points and the destination corner points (forming an A4 ratio rectangle). You would likely need to implement a process like this:
Load the captured image into an TIEBitmap. Use edge detection and possibly line detection to find the boundaries of the document. Implement logic to identify the four corner points of the document from the detected features. This might be the most complex part and could involve some custom algorithms. Define the target A4 rectangle's corners. Use IEPerspective with the source and target corners to straighten the image. 3. Converting to A4 "Document" Size
After straightening, you'll want to ensure the image has the aspect ratio of an A4 page
Yossi Mazal-Tov |
 |
|
xequte
    
39020 Posts |
|
mazluta

Israel
12 Posts |
Posted - May 21 2025 : 07:52:37
|
thanks
Yossi Mazal-Tov |
 |
|
mazluta

Israel
12 Posts |
Posted - May 21 2025 : 16:31:50
|
ok. when i load the image 2 with ImageEnView1.IO.LoadFromFileJpeg('c:\Work\MzFixImage\image\page 2.jpeg') and manipulate it with : ImageEnView1.Proc.EdgeDetect_Sobel;
and save the result with : ImageEnView1.IO.SaveToFileJpeg('c:\Work\MzFixImage\image\page 2 new.jpeg')
i get the image :

how do i get the corners ?
Yossi Mazal-Tov |
 |
|
xequte
    
39020 Posts |
|
xequte
    
39020 Posts |
|
mazluta

Israel
12 Posts |
Posted - May 22 2025 : 03:45:56
|
thanks Nigel. i hope you have good vacation.
Yossi Mazal-Tov |
 |
|
|
Topic  |
|