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

docs(warpPerspective): enhance with Kino and some text #191

Merged
merged 2 commits into from
May 6, 2023

Conversation

mnishiguchi
Copy link
Contributor

@mnishiguchi mnishiguchi commented May 5, 2023

Some enhancement to the warpPerspective notebook. Here are some of the things this PR explores.

  • Use some cool features of newer Kino
  • Remove the Livebook output
  • Make variables slightly more human friendly
  • Save the downloaded file to a tmp dir instead of current dir
  • Use the Cv alias as in some other documents
  • etc

CleanShot 2023-05-05 at 19 32 33

Comment on lines 71 to 81
@doc """
Returns the Euclidean norm.

```
{:module, Helper, <<70, 79, 82, 49, 0, 0, 10, ...>>, {:download!, 3}}
```

## Read the Test Image From File

```elixir
# Download the test image
test_image_path = Path.join(__DIR__, "warp_perspective.png")
## Examples

Helper.download!(
"https://raw.githubusercontent.com/cocoa-xu/evision/main/test/testdata/warp_perspective.png",
test_image_path
)

# Read the test image
%Evision.Mat{shape: {h, w, _}} = img = Evision.imread(test_image_path)
```

<!-- livebook:{"output":true} -->

```
%Evision.Mat{
channels: 3,
dims: 2,
type: {:u, 8},
raw_type: 16,
shape: {288, 277, 3},
ref: #Reference<0.391993608.626655254.103441>
}
iex> Helper.hypot([3, 4])
5.0
"""
def hypot([n | _] = numbers) when is_number(n) do
:math.sqrt(Enum.reduce(numbers, 0, &(&2 + &1 ** 2)))
end
Copy link
Owner

@cocoa-xu cocoa-xu May 6, 2023

Choose a reason for hiding this comment

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

Just a really minor thing here. Should we perhaps still keep it as a lambda function?

# the hypot.(list(number())) function returns the Euclidean norm
hypot = fn n ->
  :math.sqrt(Enum.reduce(numbers, 0, &(&2 + &1 ** 2)))
end

I'm thinking that it feels more natural to do it this way (writing a lambda function where one needs it)? Moreover, I'm wondering if it would be better to keep functions in Helper only relevant to preparing resources for the livebook?

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense!

@cocoa-xu cocoa-xu merged commit 21af586 into cocoa-xu:main May 6, 2023
@cocoa-xu
Copy link
Owner

cocoa-xu commented May 6, 2023

Thank you! :)

@mnishiguchi mnishiguchi deleted the docs-warp-perspective branch May 6, 2023 18:28
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.

None yet

2 participants