-
Notifications
You must be signed in to change notification settings - Fork 0
Prepare/restructure for stable RC #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… sync across Java/Python/C wrappers
|
||
cleanup: | ||
scanbotsdk_license_info_free(info); | ||
scanbotsdk_deregister_device(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deregistration is the most important part about floating license. We should add here comments that describe why should it be called and what are the consequences of not calling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated with description for both calls
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "get_license_info (before wait): %d: %s\n", ec, error_message(ec)); goto cleanup; } | ||
|
||
// Wait for the online license check to complete | ||
ec = scanbotsdk_wait_for_online_license_check_completion(15000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with constant
cleanup: | ||
scanbotsdk_license_info_free(info); | ||
scanbotsdk_deregister_device(); | ||
scanbotsdk_wait_for_device_deregistration_completion(15000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with constant
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "wait_for_online_license_check_completion: %d: %s\n", ec, error_message(ec)); goto cleanup; } | ||
|
||
// Query license info AFTER waiting for online check | ||
ec = scanbotsdk_get_license_info(&info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The info obtained above is leaked here as you no longer have a pointer to it. As we discussed, let's have to variables info_before_initialization and info_after_initialization and free both of them in the cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separated as proposed into info_before_initialization and info_after_initialization
ec = scanbotsdk_get_license_info(&info); | ||
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "get_license_info (before wait): %d: %s\n", ec, error_message(ec)); goto cleanup; } | ||
|
||
// Wait for the online license check to complete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should explain why this wait is needed - because initialize is a non-blocking operation which asynchrnously performs online license check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description on top was added
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "get_detection_result: %d: %s\n", ec, error_message(ec)); goto cleanup; } | ||
|
||
scanbotsdk_document_detection_result_get_status(detect_result, &status); | ||
printf("Document Detection Status = %d\n", (int)status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is int representation of the status useful for the user?
return ec; | ||
} | ||
|
||
printf("Detection Status = %d\n", (int)status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we print the status twice? And is int representation of the status useful fot the user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed previous condition and print
|
||
cleanup: | ||
if (blocks) free(blocks); | ||
if (lines) free(lines); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double free for lines and words can occur
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "classifier_run: %d: %s\n", ec, error_message(ec)); goto cleanup; } | ||
|
||
ec = scanbotsdk_document_classifier_result_get_status(result, &status); | ||
printf("Classifier Status: %d\n", (int)status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are int statuses here and below meaningful for the user?
scanbotsdk_document_classifier_configuration_t *config = NULL; | ||
scanbotsdk_document_classifier_result_t *result = NULL; | ||
scanbotsdk_document_classifier_t *classifier = NULL; | ||
scanbotsdk_document_scanning_result_t *scanning_result = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need scanning result here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed, no need
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "get_check: %d\n", ec); return ec; } | ||
|
||
scanbotsdk_credit_card_scanning_result_get_detection_status(result, &status); | ||
printf("Document Detection Status = %d\n", (int)status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Int status doesn't provide user with any useful information
examples/c/src/utils/utils.c
Outdated
printf("Fields count: %zu\n", fields_count); | ||
|
||
scanbotsdk_field_t **fields = calloc(fields_count, sizeof(*fields)); | ||
if (!fields) { fprintf(stderr, "alloc fields failed\n"); return SCANBOTSDK_ERROR_UNKNOWN_ERROR; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When calloc returns 0, you sometimes return OUT_OF_MEMORY, sometimes UNKNOWN ERROR. Better to return the same status in all the places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with SCANBOTSDK_ERROR_OUT_OF_MEMORY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added goto cleanup
examples/c/src/utils/utils.c
Outdated
const char *text = NULL; | ||
double confidence = 0.0; | ||
scanbotsdk_ocr_result_get_text(ocr, &text); | ||
scanbotsdk_ocr_result_get_confidence(ocr, &confidence); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid printing confidence. For non-ocred docuemnts it usually zero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed confidence getter
examples/c/src/utils/utils.c
Outdated
const char *type_name = NULL; | ||
scanbotsdk_field_type_get_name(field_type, &type_name); | ||
|
||
scanbotsdk_ocr_result_t *ocr = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not call the variable ocr as this info doesn't always come from ocr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with ocr_result
examples/c/src/utils/utils.c
Outdated
printf("Field[%zu]: type=%s, value=\"%s\", confidence=%f\n", | ||
i, type_name, text ? text : "", confidence); | ||
} else { | ||
printf("Field[%zu]: type=%s, value=(n/a)\n", i, type_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better "text value n/a", this will usually be the case from such filds as photo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated text
examples/c/src/main.c
Outdated
|
||
// TODO Add your Scanbot SDK trial license key here. | ||
// The SDK and a trial license are available on request via [email protected] | ||
char *scanbot_license_key = "<SCANBOTSDK-LICENSE>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's read license from console
examples/c/src/main.c
Outdated
scanbotsdk_error_code_t ec = scanbotsdk_initialize(¶ms); | ||
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "initialize: %d: %s\n", ec, error_message(ec)); return 1; } | ||
|
||
ec = scanbotsdk_wait_for_online_license_check_completion(15000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with constant
examples/c/src/main.c
Outdated
|
||
cleanup: | ||
scanbotsdk_deregister_device(); | ||
scanbotsdk_wait_for_device_deregistration_completion(15000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with constant
examples/c/src/main.c
Outdated
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "license_wait: %d: %s\n", ec, error_message(ec)); goto cleanup; } | ||
|
||
if (strcmp(category, "scan") == 0) { | ||
if (!file_path) { print_usage(argv[0]); return 1; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No deregistration occurs in case of early outs. Should be goto cleanup. And image should also be freed there. Same for all ealy outs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored every place with goto cleanup
else if (strcmp(category, "classify") == 0) { | ||
if (!file_path) { print_usage(argv[0]); return 1; } | ||
|
||
scanbotsdk_image_t *image = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
image is not freed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored with
scanbotsdk_image_free(image);
at the end of condition
Add snippets for nodejs wrapper
… commens and separated functions
…s for scanner/result/etc.
No description provided.