-
Notifications
You must be signed in to change notification settings - Fork 6
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
zero: meta-csp: add image capture capability for scsat1 #53
base: main
Are you sure you want to change the base?
Conversation
Implemented functionality to capture images (photos) using the camera on scsat1. Modified the camera service to use `libcamerify` in front of the program to ensure compatibility with libcamera. Utilized `v4l2` for direct image capture from the camera. This adds the capability to capture images from the camera on scsat1. Signed-off-by: Gaetan Perrot <[email protected]>
Change JPEG quality from default value 75 to 90. Currently set as a define value, not a user configuration. Signed-off-by: Gaetan Perrot <[email protected]>
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 encode to JPEG in the first place. Was it a requirement?
|
||
#define CAM_FRAME_PATH "/storageA/photo" | ||
#define CAM_FRAME_PREFIX "frame" | ||
|
||
static int xioctl(int fd, int request, void *arg) | ||
{ | ||
for (;;) { |
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.
I don't want to have infinit loops in space grade software. I know we have it in Zephyr kernel and libcsp right now. But this whole xioctl()
thing is a way for ordinal software, such as editors, language runtime, and many others. That's why AI uses it. (I'm assuming it's generated)
static void get_next_filename(char *filename, size_t size) | ||
{ | ||
unsigned num = 0; | ||
while (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.
ditto.
jpeg_destroy_compress(&cinfo); | ||
} | ||
|
||
// Function to capture images |
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 C++ comment style.
} | ||
close(fd); | ||
|
||
rgbbuf = malloc(3 * length); |
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.
Do not use literal numbers. Define it if you need.
@@ -100,6 +333,11 @@ void capture_frame_service(csp_conn_t *conn) | |||
(void)capture_frame(); | |||
} | |||
|
|||
void capture_jpeg_service(csp_conn_t *conn) | |||
{ | |||
(void)camera_jpeg("/dev/video0"); |
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.
Define "/dev/video0"
.
#define PORT_T (11U) /* for get temperature */ | ||
#define PORT_I (12U) /* for init photo dir */ | ||
#define PORT_C (13U) /* for capture frame */ | ||
#define PORT_J (15U) /* for capture JPEG*/ | ||
#define PORT_F (14U) /* for get frame count */ |
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.
Not for this PR, but can we straighten this out? What's the point of having port definitions with alphabet characters that don't align with unordered port numbers?
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.
This is because I implemented PORT_T
, among others, after PORT_A
.
I wanted to make the PORT_XX
part more meaningful, like using 'T' for Temperature, but I think that it hsn't been very effective.
I think it's better to change it to defines like PORT_GET_TEMPERATURE
in a separate PR.
|
||
#ifdef __ARM_NEON__ | ||
/* | ||
* Based on libyuv/source/row_neon.cc [https://code.google.com/p/libyuv] |
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.
- Have you checked the license of libyuv?
- Why did you copy & past a file from libyuv instead of lintegrate libyuv?
@@ -43,6 +43,10 @@ void *handle_csp_packet(void *param) | |||
csp_buffer_free(packet); | |||
break; | |||
|
|||
case PORT_J: | |||
capture_jpeg_service(conn); | |||
csp_buffer_free(packet); |
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.
Not for this PR but we must move csp_buffer_free() out of each case?
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.
I agree it.
I think it would be better to free it within xx_service
, similar to the standard csp_service_handler
in CSP.
I asked @moonlight83340 to encode it to JPEG, but this is not a must requirement.
|
OK. But, to make the code easier, I'm sure it's easier to just write out the buffer to a file; No conversion needed. OTOH, it is indeed easier to check the writen file by image viewer if the file is econded in JPEG. We should keep all images in raw format. Format conversion should be done on either with downlink command with on-the-fly conversion, or a dedicated command, IMHO. |
Thank you for your feedback. I initially thought it was necessary to save in JPEG format in case of low downlink rates, but as you pointed out, I reconsidered and decided to unify all storage in raw format:
@moonlight83340 |
Just curious, do you know
|
I don't have answers to these questions because I haven't investigate the Arducam camera driver.
I would like to ask @moonlight83340 to look into these matters as well. |
🤣 |
Implemented functionality to capture images (photos) using the camera on scsat1.
Modified the camera service to use
libcamerify
in front of the program toensure compatibility with libcamera.
Utilized
v4l2
for direct image capture from the camera.This adds the capability to capture images from the camera on scsat1.
Change JPEG quality from default value 75 to 90.
Currently set as a define value, not a user configuration.