...
 
Commits (6)
/mipi-grbg8-1x1
/mipi-grbg8-vga
/mipi-y10-1x1-file
/mipi-y12-1x1-file
/mipi-y8-1x1
/mipi-y8-1x1-file
/mipi-y8-2x2
/mipi-y8-vga
/raw2ppm
......@@ -4,6 +4,9 @@ srcdir ?= $(dir $(firstword ${MAKEFILE_LIST}))
VPATH = ${srcdir}
AM_CFLAGS = -std=gnu11 -Wall -W -Wno-unused-parameter
CFLAGS ?= -D_FORTIFY_SOURCE=2 -O1 -g3 -Werror
INSTALL = install
INSTALL_BIN = ${INSTALL} -p -m 0755
INSTALL_DATA = ${INSTALL} -p -m 0644
......@@ -23,26 +26,39 @@ bin_SCRIPTS = \
mipi-grbg8-1x1 \
mipi-grbg8-vga \
mipi-y8-1x1 \
mipi-y8-1x1-file \
mipi-y8-2x2 \
mipi-y8-vga \
mipi-y10-1x1-file \
mipi-y12-1x1-file \
pkglibexec_DATA = \
func
all:
bin_PROGRAMS = \
raw2ppm
all: ${bin_PROGRAMS}
install: .install-bin_SCRIPTS .install-pkglibexec_DATA
install: .install-bin_SCRIPTS .install-bin_PROGRAMS .install-pkglibexec_DATA
clean:
.install-bin_SCRIPTS: ${bin_SCRIPTS}
.install-bin_PROGRAMS: ${bin_PROGRAMS}
${MKDIR_P} '${DESTDIR}${bindir}'
${INSTALL_BIN} $^ '${DESTDIR}${bindir}'
.install-bin_SCRIPTS: ${bin_SCRIPTS}
${MKDIR_P} '${DESTDIR}${bindir}'
${INSTALL_BIN} $^ '${DESTDIR}${bindir}'
.install-pkglibexec_DATA: ${pkglibexec_DATA}
${MKDIR_P} '${DESTDIR}${pkglibexecdir}'
${INSTALL_DATA} $^ '${DESTDIR}${pkglibexecdir}'
%: %.c
${CC} ${AM_CFLAGS} ${CFLAGS} ${AM_LDFLAGS} ${LDFLAGS} $< -o $@
%: %.in
rm -f $@
${SED} ${SED_EXPR} $< > $@
......
......@@ -2,12 +2,29 @@
set -e
: ${NUM_FRAMES:=10}
parm_y8() {
CAM_FMT=Y8_1X8
PIX_FMT=Y8
GST_FMT=video/x-raw,format=GRAY8
GST_CONVERT=( )
}
parm_y10() {
CAM_FMT=Y10_1X10
PIX_FMT=Y10
GST_FMT=video/x-raw,format=Y10
GST_CONVERT=( )
}
parm_y12() {
CAM_FMT=Y12_1X12
PIX_FMT=Y12
GST_FMT=video/x-raw,format=Y12
GST_CONVERT=( )
}
parm_grbg8() {
CAM_FMT=GRBG
PIX_FMT=SGRBG8
......@@ -40,6 +57,8 @@ parm_geo() {
CTLS_geo=(
--set-fmt-video=width=$GRAB_X,height=$GRAB_Y,pixelformat=$CAM_FMT
--set-selection=target=crop,left=$[ $1 + 6 ],top=$[ $2 + 10 ],width=$X,height=$Y
-c horizontal_skipping=$5
-c vertical_skipping=$6
)
CROP_RES="${X}x${Y}"
......@@ -84,5 +103,5 @@ run_gst() {
}
run_yavta() {
yavta "$VID_DEVICE" -f "$PIX_FMT" -s "${X}x${Y}" -c --file=/tmp/frame-\#.raw
yavta "$VID_DEVICE" -f "$PIX_FMT" -s "${X}x${Y}" --capture${NUM_FRAMES:+=$NUM_FRAMES} --file=/tmp/frame-\#.raw
}
#! /bin/bash
. @PKGLIBEXECDIR@/func
parm_mipi "${1:-0}"
parm_y10
parm_geo 0 0 1280 800 0 0
$SETUP_MEIDACTL_FN "$CAM_FMT/$GRAB_RES" "$TOP/$CROP_RES" "${2:-1/60}"
run_yavta
#! /bin/bash
. @PKGLIBEXECDIR@/func
parm_mipi "${1:-0}"
parm_y12
parm_geo 0 0 1280 800 0 0
$SETUP_MEIDACTL_FN "$CAM_FMT/$GRAB_RES" "$TOP/$CROP_RES" "${2:-1/60}"
run_yavta
#! /bin/bash
. @PKGLIBEXECDIR@/func
parm_mipi "${1:-0}"
parm_y8
parm_geo 0 0 1280 800 0 0
$SETUP_MEIDACTL_FN "$CAM_FMT/$GRAB_RES" "$TOP/$CROP_RES" "${2:-1/60}"
run_yavta
#! /bin/bash
. @PKGLIBEXECDIR@/func
parm_mipi "${1:-0}"
parm_y8
parm_geo 0 0 1280 800 1 1
$SETUP_MEIDACTL_FN "$CAM_FMT/$GRAB_RES" "$TOP/$CROP_RES" "${2:-1/60}"
run_gst
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <endian.h>
int main(int argc, char *argv[])
{
unsigned int w = atoi(argv[1]);
unsigned int h = atoi(argv[2]);
unsigned int c = atoi(argv[3]);
unsigned int bytes_per_pix = (c + 7) / 8;
size_t imgsz = w * h * bytes_per_pix;
void *buf = malloc(imgsz);
if (!buf)
abort();
if (fread(buf, imgsz, 1, stdin) != 1)
abort();
printf("P2 %u %u %u\n", w, h, (1u << c) - 1u);
for (size_t i = 0; i < imgsz; i += bytes_per_pix) {
union {
uint8_t u8;
uint16_t u16;
} const *p = buf + i;
unsigned int pix;
switch (bytes_per_pix) {
case 1:
pix = p->u8;
break;
case 2:
pix = le16toh(p->u16);
break;
default:
abort();
}
if (pix >= (1u << c)) {
fprintf(stderr, "pix value %04x out of range\n", pix);
abort();
}
printf("%u%c", pix, (i + bytes_per_pix) % 64 == 0 ? '\n' : ' ');
}
if (imgsz % 64 != 0)
printf("\n");
}