Skip to content
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

Compiler warnings #7

Closed
hafedh-trimeche opened this issue May 7, 2023 · 3 comments
Closed

Compiler warnings #7

hafedh-trimeche opened this issue May 7, 2023 · 3 comments

Comments

@hafedh-trimeche
Copy link

Hi,

Please note these compiler warnings:

[dcc64 Warning] unOpenCVDelphi46.pas(263): W1036 Variable 'mt' might not have been initialized
[dcc64 Warning] unOpenCVDelphi46.pas(786): W1073 Combining signed type and unsigned 64-bit type - treated as an unsigned type
[dcc64 Warning] unOpenCVDelphi46.pas(834): W1036 Variable 'vecNmsIndex' might not have been initialized
[dcc64 Warning] unOpenCVDelphi46.pas(832): W1036 Variable 'vecBoxes' might not have been initialized
[dcc64 Warning] unOpenCVDelphi46.pas(833): W1036 Variable 'vecScores' might not have been initialized
[dcc64 Warning] unOpenCVDelphi46.pas(840): W1036 Variable 'classIdPoint' might not have been initialized
[dcc64 Warning] unOpenCVDelphi46.pas(830): W1036 Variable 'img' might not have been initialized

Best regards.

@gidesa
Copy link
Owner

gidesa commented May 7, 2023

Hello,
the first warning on mt is clearly ininfluent.
With my compiler (32bit) there is no warning on signed/unsigned.
The others warnings complain from some unitialized variables, but they are always initialized, in instructions sequence out of conditionals, and then always executed. So compiler is too much restrictive.
For example: vecBoxes initialized in vecBoxes:=pCvVectorRect2dCreate(detections.Count);
vecNmsIndex in vecNmsIndex:=pCvVectorintCreate(0);
and so on.

@gidesa gidesa closed this as completed May 7, 2023
@hafedh-trimeche
Copy link
Author

hafedh-trimeche commented May 7, 2023

Hi,

vecNmsIndex must be defined outside Try Finally block because if an exception is raised, vecNmsIndex has no value and would generate another exception when calling pCvVectorintDelete(vecNmsIndex);

dptr := dptr + outW*SizeOf(single);
Change to
dptr := dptr + UInt64(outW)*SizeOf(single);

 Assert((nchannels=1) or (nchannels=3),'Channels number must be 1, 2 or 3');
 case nchannels of
  1:  mt:=CV_8UC1;
  2:  mt:=CV_8UC2;
  3:  mt:=CV_8UC3;
 end;

Change to

  Assert((nchannels>=1) and (nchannels<=3),'Channels number must be 1, 2 or 3');
  mt:=CV_8UC1;
  case nchannels of
   2:  mt:=CV_8UC2;
   3:  mt:=CV_8UC3;
  end;

vecBoxes, classIdPoint and vecScores same as vecNmsIndex

img must be set to nil before the Try Finally Block.

Best regards.

@gidesa
Copy link
Owner

gidesa commented May 23, 2023

Hello, regarding your good advise to reorganize try ... finally blocks, I released the corrected version of unOpencvDelphi46.pas.
Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants