Skip to content

Commit

Permalink
Update shared libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
yushulx committed Aug 16, 2024
1 parent 9f40c66 commit fdd67ed
Show file tree
Hide file tree
Showing 47 changed files with 169 additions and 55 deletions.
93 changes: 93 additions & 0 deletions camera_async_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import argparse
import docscanner
import sys
import numpy as np
import cv2
import time

g_results = None
g_normalized_images = []


def callback(results):
global g_results
g_results = results


def showNormalizedImage(name, normalized_image):
mat = docscanner.convertNormalizedImage2Mat(normalized_image)
cv2.imshow(name, mat)
return mat


def process_video(scanner):
scanner.addAsyncListener(callback)

cap = cv2.VideoCapture(0)
while True:
ret, image = cap.read()

ch = cv2.waitKey(1)
if ch == 27:
break
elif ch == ord('n'): # normalize image
if g_results != None:
g_normalized_images = []
index = 0
for result in g_results:
x1 = result.x1
y1 = result.y1
x2 = result.x2
y2 = result.y2
x3 = result.x3
y3 = result.y3
x4 = result.x4
y4 = result.y4

normalized_image = scanner.normalizeBuffer(
image, x1, y1, x2, y2, x3, y3, x4, y4)
g_normalized_images.append(
(str(index), normalized_image))
mat = showNormalizedImage(str(index), normalized_image)
index += 1
elif ch == ord('s'): # save image
for data in g_normalized_images:
# cv2.imwrite('images/' + str(time.time()) + '.png', image)
cv2.destroyWindow(data[0])
data[1].save(str(time.time()) + '.png')
print('Image saved')

g_normalized_images = []

if image is not None:
scanner.detectMatAsync(image)

if g_results != None:
for result in g_results:
x1 = result.x1
y1 = result.y1
x2 = result.x2
y2 = result.y2
x3 = result.x3
y3 = result.y3
x4 = result.x4
y4 = result.y4

cv2.drawContours(
image, [np.intp([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)

cv2.putText(image, 'Press "n" to normalize image',
(10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), 2)
cv2.putText(image, 'Press "s" to save image', (10, 60),
cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), 2)
cv2.putText(image, 'Press "ESC" to exit', (10, 90),
cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), 2)
cv2.imshow('Document Scanner', image)


docscanner.initLicense(
"DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==")

scanner = docscanner.createInstance()
ret = scanner.setParameters(docscanner.Templates.color)
process_video(scanner)
64 changes: 39 additions & 25 deletions include/DynamsoftCore.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __DYNAMSOFT_CORE_H__
#define __DYNAMSOFT_CORE_H__

#define DYNAMSOFT_CORE_VERSION "2.0.0.0508"
#define DYNAMSOFT_CORE_VERSION "2.0.1.0929"

/**Successful. */
#define DM_OK 0
Expand Down Expand Up @@ -81,17 +81,20 @@
#define DMERR_GET_MODE_ARGUMENT_ERROR -10055

/**No content has been detected.*/
#define DDN_CONTENT_NOT_FOUND -10056
#define DDNERR_CONTENT_NOT_FOUND -50001

/*The quardrilateral is invalid*/
#define DDN_QUADRILATERAL_INVALID -10057
#define DMERR_QUADRILATERAL_INVALID -10057

/**Failed to save file.*/
#define DMERR_FILE_SAVE_FAILED -10058

/**The stage type is invalid.*/
#define DMERR_STAGE_TYPE_INVALID -10059

/**The image orientation is invalid.*/
#define DMERR_IMAGE_ORIENTATION_INVALID -10060

#ifndef _COMMON_PART1_
#define _COMMON_PART1_

Expand Down Expand Up @@ -390,13 +393,13 @@ typedef enum BarcodeFormat
{
/**All supported formats in BarcodeFormat group 1*/
#if defined(_WIN32) || defined(_WIN64)
BF_ALL = 0xFE1FFFFF,
BF_ALL = 0xFE3FFFFF,
#else
BF_ALL = -31457281,
BF_ALL = -29360129,
#endif

/**Combined value of BF_CODABAR, BF_CODE_128, BF_CODE_39, BF_CODE_39_Extended, BF_CODE_93, BF_EAN_13, BF_EAN_8, INDUSTRIAL_25, BF_ITF, BF_UPC_A, BF_UPC_E, BF_MSI_CODE; */
BF_ONED = 0x001007FF,
/**Combined value of BF_CODABAR, BF_CODE_128, BF_CODE_39, BF_CODE_39_Extended, BF_CODE_93, BF_EAN_13, BF_EAN_8, INDUSTRIAL_25, BF_ITF, BF_UPC_A, BF_UPC_E, BF_MSI_CODE ,BF_ONED; */
BF_ONED = 0x003007FF,

/**Combined value of BF_GS1_DATABAR_OMNIDIRECTIONAL, BF_GS1_DATABAR_TRUNCATED, BF_GS1_DATABAR_STACKED, BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL, BF_GS1_DATABAR_EXPANDED, BF_GS1_DATABAR_EXPANDED_STACKED, BF_GS1_DATABAR_LIMITED*/
BF_GS1_DATABAR = 0x0003F800,
Expand Down Expand Up @@ -489,6 +492,10 @@ typedef enum BarcodeFormat
/**MSI Code*/
BF_MSI_CODE = 0x100000,

/*Code 11*/
BF_CODE_11 = 0x200000,


/**No barcode format in BarcodeFormat group 1*/
BF_NULL = 0x00

Expand All @@ -506,35 +513,38 @@ typedef enum BarcodeFormat_2
/**No barcode format in BarcodeFormat group 2*/
BF2_NULL = 0x00,

/**Combined value of BF2_USPSINTELLIGENTMAIL, BF2_POSTNET, BF2_PLANET, BF2_AUSTRALIANPOST, BF2_RM4SCC.
When you set this barcode format, the library will automatically add LM_STATISTICS_POSTAL_CODE to LocalizationModes if you doesn't set it.*/
/**Combined value of BF2_USPSINTELLIGENTMAIL, BF2_POSTNET, BF2_PLANET, BF2_AUSTRALIANPOST, BF2_RM4SCC.*/
BF2_POSTALCODE = 0x01F00000,

/**Nonstandard barcode */
BF2_NONSTANDARD_BARCODE = 0x01,

/**USPS Intelligent Mail.
When you set this barcode format, the library will automatically add LM_STATISTICS_POSTAL_CODE to LocalizationModes if you doesn't set it.*/
/**USPS Intelligent Mail.*/
BF2_USPSINTELLIGENTMAIL = 0x00100000,

/**Postnet.
When you set this barcode format, the library will automatically add LM_STATISTICS_POSTAL_CODE to LocalizationModes if you doesn't set it.*/
/**Postnet.*/
BF2_POSTNET = 0x00200000,

/**Planet.
When you set this barcode format, the library will automatically add LM_STATISTICS_POSTAL_CODE to LocalizationModes if you doesn't set it.*/
/**Planet.*/
BF2_PLANET = 0x00400000,

/**Australian Post.
When you set this barcode format, the library will automatically add LM_STATISTICS_POSTAL_CODE to LocalizationModes if you doesn't set it.*/
/**Australian Post.*/
BF2_AUSTRALIANPOST = 0x00800000,

/**Royal Mail 4-State Customer Barcode.
When you set this barcode format, the library will automatically add LM_STATISTICS_POSTAL_CODE to LocalizationModes if you doesn't set it.*/
/**Royal Mail 4-State Customer Barcode.*/
BF2_RM4SCC = 0x01000000,

/**DotCode. When you set this barcode format, the library will automatically add LM_STATISTICS_MARKS to LocalizationModes if you doesn't set it.*/
BF2_DOTCODE = 0x02
/**DotCode.*/
BF2_DOTCODE = 0x02,

/**_PHARMACODE_ONE_TRACK.*/
BF2_PHARMACODE_ONE_TRACK = 0x04,

/**PHARMACODE_TWO_TRACK.*/
BF2_PHARMACODE_TWO_TRACK = 0x08,

/**PHARMACODE.*/
BF2_PHARMACODE = 0x0C
}BarcodeFormat_2;


Expand Down Expand Up @@ -579,6 +589,9 @@ typedef struct tagImageData

/**The image pixel format used in the image byte array.*/
ImagePixelFormat format;

/**The image orientation.*/
int orientation;
}ImageData;


Expand Down Expand Up @@ -708,10 +721,10 @@ namespace dynamsoft
int height;
int stride;
ImagePixelFormat format;

int orientation;
public:
CImageData();
CImageData(int _l, unsigned char* _b, int _w, int _h, int _s, ImagePixelFormat _f);
CImageData(int _l, unsigned char* _b, int _w, int _h, int _s, ImagePixelFormat _f, int _o = 0);
~CImageData();

const unsigned char* const GetBytes() const;
Expand All @@ -720,10 +733,11 @@ namespace dynamsoft
int GetHeight() const;
int GetStride() const;
ImagePixelFormat GetImagePixelFormat() const;
int GetOrientation() const;

private:
CImageData(const CImageData&);
CImageData& operator=(const CImageData&);
CImageData(const CImageData&) = delete;
CImageData& operator=(const CImageData&) = delete;
};

#pragma pack(pop)
Expand Down
7 changes: 3 additions & 4 deletions include/DynamsoftDocumentNormalizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#else
#include "DynamsoftCore.h"
#endif
#define DDN_VERSION "1.0.0.0124"
#define DDN_VERSION "1.0.30.0602"

#pragma pack(push)
#pragma pack(1)
Expand Down Expand Up @@ -74,7 +74,7 @@ extern "C" {

DDN_API void DDN_FreeDetectedQuadResultArray(DetectedQuadResultArray** results);

DDN_API int DDN_SaveImageDataToFile(const ImageData* imageData, const char * filePath);
DDN_API int NormalizedImageResult_SaveToFile(const NormalizedImageResult* normalizedImageResult, const char* filePath);

#ifdef __cplusplus
}
Expand Down Expand Up @@ -138,7 +138,7 @@ namespace dynamsoft
public:
CNormalizedImageResult(core::CImageData* img);
~CNormalizedImageResult();

int SaveToFile(const char* filePath);
const core::CImageData* GetImageData();

private:
Expand Down Expand Up @@ -181,7 +181,6 @@ namespace dynamsoft

static void FreeString(char** content);

static int SaveImageDataToFile(const core::CImageData* imageData, const char * filePath);

private:
CDocumentNormalizer(const CDocumentNormalizer& r);
Expand Down
Binary file added lib/linux/libDynamicImage.so
Binary file not shown.
Binary file added lib/linux/libDynamicPdf.so
Binary file not shown.
Binary file added lib/linux/libDynamicPdfCore.so
Binary file not shown.
Binary file modified lib/linux/libDynamsoftCore.so
Binary file not shown.
Binary file modified lib/linux/libDynamsoftDocumentNormalizer.so
Binary file not shown.
Binary file modified lib/linux/libDynamsoftImageProcessing.so
Binary file not shown.
Binary file modified lib/linux/libDynamsoftIntermediateResult.so
Binary file not shown.
Binary file added lib/win/DynamicImagex64.dll
Binary file not shown.
Binary file added lib/win/DynamicPdfCorex64.dll
Binary file not shown.
Binary file added lib/win/DynamicPdfx64.dll
Binary file not shown.
Binary file modified lib/win/DynamsoftCorex64.dll
Binary file not shown.
Binary file modified lib/win/DynamsoftCorex64.lib
Binary file not shown.
Binary file modified lib/win/DynamsoftDocumentNormalizerx64.dll
Binary file not shown.
Binary file modified lib/win/DynamsoftDocumentNormalizerx64.lib
Binary file not shown.
Binary file modified lib/win/DynamsoftImageProcessingx64.dll
Binary file not shown.
Binary file modified lib/win/DynamsoftIntermediateResultx64.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-core-file-l1-2-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-core-file-l2-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-core-localization-l1-2-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-core-processthreads-l1-1-1.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-core-synch-l1-2-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-core-timezone-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-conio-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-convert-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-environment-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-filesystem-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-heap-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-locale-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-math-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-multibyte-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-runtime-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-stdio-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-string-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-time-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/api-ms-win-crt-utility-l1-1-0.dll
Binary file not shown.
Binary file removed lib/win/concrt140.dll
Binary file not shown.
Binary file removed lib/win/msvcp140.dll
Binary file not shown.
Binary file removed lib/win/msvcp140_1.dll
Binary file not shown.
Binary file removed lib/win/msvcp140_2.dll
Binary file not shown.
Binary file removed lib/win/ucrtbase.dll
Binary file not shown.
Binary file removed lib/win/vccorlib140.dll
Binary file not shown.
Binary file removed lib/win/vcruntime140.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def copyfiles(src, dst):
else:
shutil.copy2(src, dst)


class CustomBuildExt(build_ext.build_ext):
def run(self):
build_ext.build_ext.run(self)
Expand Down Expand Up @@ -111,6 +112,8 @@ def run(self):
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: C++",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering",
Expand Down
Loading

0 comments on commit fdd67ed

Please sign in to comment.