From patchwork Fri Aug 5 18:18:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16989 X-Patchwork-Delegate: umang.jain@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 29FE7C3275 for ; Fri, 5 Aug 2022 18:19:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 91F37603E4; Fri, 5 Aug 2022 20:19:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659723542; bh=ZhNavlpmdRSddSQo8QA2pmbNcVOml11Ur7hNgZEMLEM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=dSGeDmItjgYg7xtj4zq9CGrQ1qT4+lT7zTEjlhxXoftPVukRRzWXDirO1oEUGXSxp qPglM+zCsN+cyafgyEKvqaNDAcrkYW+SWdD5pkYT8wqBDadCmYD9RfPF/ZJbpAmtHw D9EFRRBaluEX+Bel9+9GH5V/LmxonE/jkz1QO38yPp826G5X8ynNfn19aPaQKGdIVb FPDxY/+fpe7sffm+VaFYfnDr7QjDw+hICF94ov+T0arVP7GUJEHLG9JbEhkrVcjbY5 MnKFprrpTwI4xxhQLZBs2Sa+kONqc4zUc+6gzyI07xc8XO/vCfA8PLt7rFm1evTYa+ uVCmvqKmCVVoQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4FF0F603E4 for ; Fri, 5 Aug 2022 20:19:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="o4I/5B88"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [IPv6:2401:4900:1f3e:69e0:a479:4ccc:ab2a:bf48]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4A9A26E0; Fri, 5 Aug 2022 20:19:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659723541; bh=ZhNavlpmdRSddSQo8QA2pmbNcVOml11Ur7hNgZEMLEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o4I/5B88+Zvp1Q9knRNCgP6daIRHr0TJMN+aw38WSAuiP3kYVRnVUL+Rh8LNLHA7+ dgbM4kPIzWG7Im50vSt9wU+iT56Mqym1WGwPzBC6xDTFGZTIfqZAy3c3N0+46XL4kx 0lIIRsgfvZPTd1Ahkmaus4STHbJtpcmxWgzZgrY8= To: libcamera-devel@lists.libcamera.org Date: Fri, 5 Aug 2022 23:48:47 +0530 Message-Id: <20220805181850.848886-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220805181850.848886-1-umang.jain@ideasonboard.com> References: <20220805181850.848886-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] utils: ipu3: Helper to generate IMGU input streaming file X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Usage: ipu3-gen-imgu-input.sh --count --size The input file is generated in 10-bit bayer which can be directly streamed to IMGU. Each frame (starting from 0) has a black background with a visible "Frame " label in the center. Signed-off-by: Umang Jain --- utils/ipu3/ipu3-gen-imgu-input.sh | 78 +++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 utils/ipu3/ipu3-gen-imgu-input.sh diff --git a/utils/ipu3/ipu3-gen-imgu-input.sh b/utils/ipu3/ipu3-gen-imgu-input.sh new file mode 100755 index 00000000..ea0d385d --- /dev/null +++ b/utils/ipu3/ipu3-gen-imgu-input.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2022, Google Inc. +# +# Author: Umang Jain +# +# ipu3-gen-imgu-input.sh - Generate input file for IMGU streaming +# +# The scripts makes use of the following tools, which are expected to be +# found in $PATH: +# +# - raw2pnm (from nvt https://github.com/intel/nvt.git) +# - pnm2raw (from nvt https://github.com/intel/nvt.git) +# - ipu-pack (from https://git.libcamera.org/libcamera/libcamera.git/) +# - convert (from https://github.com/ImageMagick/ImageMagick/tree/main/utilities) + +#default frame count +frame_count=10 + +validate_size() { + local size=$1 + local width=$(echo $size | awk -F 'x' '{print $1}') + local height=$(echo $size | awk -F 'x' '{print $2}') + + [[ "x${size}" == "x${width}x${height}" ]] +} + +# Print usage message +usage() { + echo "Usage: $(basename $1) --count --size " + echo "Supported options:" + echo "--count count Generate input file containing frames, default=10" + echo "--size size Frame size ('width' x 'height')" + echo "" +} + +# Parse command line arguments +while (( "$#" )) ; do + case $1 in + --count) + frame_count=$2 + shift 2 + ;; + --size) + in_size=$2 + if ! validate_size $in_size ; then + echo "Invalid size '$in_size'" + usage $0 + exit 1 + fi + shift 2 + ;; + -*) + echo "Unsupported option $1" >&2 + usage $0 + exit 1 + ;; + *) + break + ;; + esac +done + +if [[ -z ${in_size+x} ]] ; then + usage $0 + exit 1 +fi + +echo "Generating Input file frame-$in_size.raw" +for i in `seq 0 $(expr $frame_count - 1)` +do + convert -background "#000000" -size $in_size -fill "#ffffff" -pointsize 120 -gravity center label:"Frame $i" frame-$i.ppm + pnm2raw frame-$i.ppm frame-$i.raw + ipu3-pack frame-$i.raw - >> frame-$in_size.raw + + rm frame-$i.ppm + rm frame-$i.raw +done