Skip to content

Conversation

@catmajor
Copy link
Member

Create basic CLI client for ARFlow in python
Provide a variety of APIs, some of which closely resemble those found in the Unity Client to provide functions for clients

catmajor added 9 commits June 6, 2025 15:59
-Some nuances are not in this version such as the logger middleware/advanced http options
-I am not sure about what model is so I am leaving it as the concatenation of the operating system name and its version
-Type needs to be changed later to be assigned propertly, for now only uses 3 as this is for the cli which only runs on desktops
-Currently unable to gather data (coming soon)
-Will not leave sessions (will be implemented with data gathering)
…llow CamelCase from the original GrpcClient.cs
-Currently only able to collect color frames
@YiqinZhao YiqinZhao self-requested a review June 11, 2025 22:39
Copy link
Member

@YiqinZhao YiqinZhao left a comment

Choose a reason for hiding this comment

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

Some changes are needed. Overall, you did great! I made some changes on code styling, documentations, and formatting.

@@ -0,0 +1,76 @@
import grpc
Copy link
Member

Choose a reason for hiding this comment

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

We should always add a leading docstring for Python scripts.

Copy link
Member

Choose a reason for hiding this comment

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

Please check https://github.com/catmajor/ARFlow/pull/1/files for some changes I made to this file. Overall, you did great. I made some changes on code styling, documentations, and formatting.

class GrpcClient:
def __init__(self, url):
self.channel = grpc.insecure_channel(url)
async def create_session_async(self, name: str, device: Device, save_path: str = "") -> CreateSessionResponse:
Copy link
Member

Choose a reason for hiding this comment

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

Change return type in the function definition to Awaitable[CreateSessionResponse].

session_metadata=SessionMetadata(name=name, save_path=save_path),
device=device
)
response: Awaitable[CreateSessionResponse] = ARFlowServiceStub(self.channel).CreateSession(request)
Copy link
Member

Choose a reason for hiding this comment

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

ARFlowServiceStub can be reused?

)
response: Awaitable[CreateSessionResponse] = ARFlowServiceStub(self.channel).CreateSession(request)
return response
async def delete_session_async(self, session_id: str) -> DeleteSessionResponse:
Copy link
Member

Choose a reason for hiding this comment

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

Need an empty line between L35 and L34.

@@ -0,0 +1,136 @@


from GrpcClient import GrpcClient
Copy link
Member

Choose a reason for hiding this comment

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

Please follow my changes in https://github.com/catmajor/ARFlow/pull/1/files to update this and other files as well.

@catmajor catmajor changed the title Add ARFlow python client APIs and basic CLI client Add frame by frame compression and test this compression - Nikita Ostapenko Jul 10, 2025
@catmajor
Copy link
Member Author

Frame by Frame compression

We discussed adding frame by frame compression to ARFlow as H264 compression creates a challenge in integrating chunked and compressed byte processing into existing one frame one display results. Here they are. I have incorporated a decently modified version of one of Vedant Saran's tests.

I have left in print statements despite ruff's complaints as they are not used for debugging, but rather in the application itself to display messages and UIs.

Overall Results

Uncompressed frames were by far the worst, in HD the FPS cannot even get above 5. The method requires lots of processing power and bandwidth.

PNG frames were slightly better, the HD version nearly doubled the FPS to 7, but the overall effect compared to the original H264 compression is also quite bad. However, unlike the raw frames, this method is actually bottlenecked by the processing power required to compress individual images into PNG format. This is visible through the difference between memory use between the SD and HD versions where the amount of memory actually went down due to the main bottleneck being created by compression speed rather than bandwidth use.

JPG saw the closest results to the extreme efficiency seen with H264 compression. There was a ~90% reduction in bandwidth and the frame rate actually stayed near 30 FPS for both SD and HD tests. It is important to note that JPG compression still requires heavy CPU use and for the HD version this occupied nearly 40% of my total cpu's output.

@catmajor catmajor marked this pull request as ready for review July 10, 2025 04:36
Copy link
Member

@YiqinZhao YiqinZhao left a comment

Choose a reason for hiding this comment

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

Please see the comments for some minor formatting issues.


async def __manage_sessions(self):
while True:
print("Available Sessions:")
Copy link
Member

Choose a reason for hiding this comment

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

This Ruff (T201) error needs to be addressed. Try adding either # ruff: noqa: T201 to the top of the file or using the following statements to disable the error messages on a code block:

# ruff: noqa: T201
print("This is allowed")  # Ruff will ignore T201 here
print("This is also allowed")
# ruff: enable

return response

def close(self):
"""Close the channel."""
Copy link
Member

Choose a reason for hiding this comment

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

Address this Ruff error.

Copy link
Member

@YiqinZhao YiqinZhao left a comment

Choose a reason for hiding this comment

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

LGTM

@YiqinZhao YiqinZhao merged commit 6133c27 into cake-lab:main Jul 11, 2025
1 check passed
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.

2 participants