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

Affine transform #51

Closed
wants to merge 3 commits into from
Closed

Affine transform #51

wants to merge 3 commits into from

Conversation

yashrajsapra
Copy link
Collaborator

@yashrajsapra yashrajsapra commented Jan 13, 2022

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

#36

Description

Added Affine Transform Module.
Currently supported only on jetson boards.

Alternative(s) considered

Type

Feature

Screenshots (if applicable)

Checklist

  • I have written Unit Tests
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach

@github-actions
Copy link

github-actions bot commented Jan 13, 2022

Unit Test Results

  1 files  ±0    1 suites  ±0   9s ⏱️ ±0s
98 tests ±0  68 ✔️ ±0  30 💤 ±0  0 ±0 
68 runs  ±0  38 ✔️ ±0  30 💤 ±0  0 ±0 

Results for commit 9121f34. ± Comparison against base commit 48f6c40.

♻️ This comment has been updated with latest results.

@kumaakh
Copy link
Collaborator

kumaakh commented Jan 13, 2022

Why not add a couple of test cases pls ? @yashrajsapra @joiskash

@joiskash joiskash self-requested a review January 13, 2022 15:03
Copy link
Collaborator

@joiskash joiskash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yashrajsapra for this PR! I have done an initial round of review. Please address the comments. Also as Akhil has requested , please add some unit tests. Make sure you go through the checklist before adding them.

Comment on lines 48 to 55
hunter_add_package(ncursesw)
find_package(ncursesw CONFIG REQUIRED)
SET(CURSES_INCLUDE_DIR ${NCURSESW_ROOT}/include/ncursesw)
SET(CURSES_LIBRARIES PkgConfig::ncursesw)
ENDIF(NOT ENABLE_ARM64)

IF(ENABLE_CUDA)
enable_language(CUDA)
enable_language(CUDA)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation seems wrong here

Format the code using ctrl+shift+I . Do this for all files

Comment on lines 48 to 51
hunter_add_package(ncursesw)
find_package(ncursesw CONFIG REQUIRED)
SET(CURSES_INCLUDE_DIR ${NCURSESW_ROOT}/include/ncursesw)
SET(CURSES_LIBRARIES PkgConfig::ncursesw)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you changed the indentation?

Format the code using ctrl+shift+I

Comment on lines +18 to +20
int x=0;
int y = 0;
float scale = 1.0f;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No hard coding values. Pleas remove from function definition also

}

ImageMetadata::ImageType imageType = ImageMetadata::MONO;
if (mFrameType == FrameMetadata::RAW_IMAGE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this if statement required? I think the switch case above is already taking care of this

if (mFrameType == FrameMetadata::RAW_IMAGE)
{
auto rawMetadata = FrameMetadataFactory::downcast<RawImageMetadata>(metadata);
int x, y, w, h;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is x and y? use width and height instead of w an h. Use more explanatory variable names instead of x & y

int x, y, w, h;
w = rawMetadata->getWidth();
h = rawMetadata->getHeight();
RawImageMetadata outputMetadata(w, h, rawMetadata->getImageType(), rawMetadata->getType(), 512, rawMetadata->getDepth(), FrameMetadata::DMABUF, true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the hard coded value of 512?

Comment on lines +228 to +243
FrameMetadata::FrameType mFrameType;
int depth;
int channels;
NppiSize srcSize[4];
NppiRect srcRect[4];
int srcPitch[4];
size_t srcNextPtrOffset[4];
NppiSize dstSize[4];
NppiRect dstRect[4];
int dstPitch[4];
size_t dstNextPtrOffset[4];

double shiftX;
double shiftY;
void *ctx;
NppStreamContext nppStreamCtx;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this above the function for better readability

FrameMetadata::FrameType mFrameType;
int depth;
int channels;
NppiSize srcSize[4];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments for the variables that are tough to understand explaining in one line what they are for.

si = props.scale * sin(props.angle * PI / 180);
co = props.scale * cos(props.angle * PI / 180);
double shx, shy;
shx = (1 - co) * (srcSize[0].width / 2) + si * srcSize[0].height / 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try not to use acronyms that are not standard. Not sure what shx means

{
auto frame = frames.cbegin()->second;
auto outFrame = makeFrame(mDetail->mFrameLength);
cudaFree(0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we always have to call cudaFree?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put this in processSOS

auto frame = frames.cbegin()->second;
auto outFrame = makeFrame(mDetail->mFrameLength);
cudaFree(0);
cudaMemset(static_cast<DMAFDWrapper *>(outFrame->data())->getCudaPtr(), 0, outFrame->size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to cudaMemsetAsync and pass the Cuda stream. Avoid using the default cuda stream. In Compute you are using stream so here also you can use the same

@joiskash
Copy link
Collaborator

joiskash commented Feb 2, 2022

@yashrajsapra please update this branch and lets try to close it by this week. We only need to support DMA and GPU . Later enhancement can be to check pin input type and then based on that use DMA/GPU or CPU memory

@joiskash
Copy link
Collaborator

@yashrajsapra any updates?

@mraduldubey
Copy link
Collaborator

This has a been addressed in #227 now

@yashrajsapra yashrajsapra deleted the AffineTransform branch March 6, 2024 06:15
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

Successfully merging this pull request may close these issues.

4 participants