unity使ui面向镜头

Note: This article is part of a series of articles aimed at describing the complete process of creation of this project. You can read about the story behind this full project here and the related 3D case design here.

注意:本文是一系列文章的一部分,旨在描述该项目的完整创建过程。 你可以阅读这个完整的项目背后的故事 在这里 和相关的3D外壳设计 在这里

When you are creating a full project from scratch, often based on a late-night idea that keeps you awake for the rest of the night, it always drives you to multiple stages to reach your final destination. It usually starts on a simple concept, followed by some tweaking and messing around with bunch of wires and sensors (especially when you are like me, often in the Raspberry Pi universe), up to the point when you reach “something that works”. However, when you intend to share your project with others, you often look back and tell yourself that it could do with a little bit more polishing than the original attempt. I feel that there is nothing worse than a project that you intend to try and as opposed to be a straight forward set of instructions, it sometimes ends up as a full-night browsing for answers to why you get the XYZ error message.

当您从头开始创建一个完整的项目时,通常基于一个使您在整个晚上都保持清醒的深夜想法,它总是将您带到多个阶段以到达最终目的地。 它通常从一个简单的概念开始,然后进行一些调整和弄乱电线和传感器(特别是当您像我一样,通常在Raspberry Pi领域中),直到达到“可行的东西”为止。 但是,当您打算与他人共享项目时,您经常回头告诉自己,与最初的尝试相比,它可以做得更多。 我觉得没有什么比您打算尝试的项目更糟糕的了,而不是简单明了的说明,它有时会变成一整夜的浏览,以寻找获得XYZ错误消息的答案。

This is why it took me a little bit more time to complete this third part of the PiHQCam project as I intended to provide all the necessary instructions for people to be able to deploy from a clean Raspberry environment. Also, this is the first stage of software features that I intended to include in the project. I already have additional features that I intend to bring into the main stack of the application. Now is the time to get your PiHQCam “software-ready” as well as to go through its interface and set of features.

这就是为什么我花了一些时间来完成PiHQCam项目的第三部分,因为我打算为人们提供所有必要的指导,以便人们能够从干净的Raspberry环境进行部署。 而且,这是我打算在项目中包括的软件功能的第一阶段。 我已经准备将其他功能带入应用程序的主堆栈。 现在是时候让您的PiHQCam“软件就绪”以及通过其界面和功能集了。

”软件安装 (“Engage” the software installation)

基本系统配置 (Base system configuration)

We’ll start from a clean installation of the Raspberry Pi OS, previously called Raspbian, based on its Buster revision. However, as opposed to start with the standard distribution that includes all the graphical interface & components, I preferred to start from its “lite” version. The reason is that as we intend to use directly the camera, we don’t want to install software that we won’t be using at all such as spreadsheet and word processors. Also, originally, I was hoping to use directly the “preview” mode of the Raspberry Pi Camera module, as it also works without from problem, from the command line. However, I had to revise this angle during the development phase as it turned out to be incompatible with the framework I had decided to use for the project.

我们将从全新安装的Raspberry Pi OS(先前称为Raspbian)开始,基于其Buster版本。 但是,相对于从包含所有图形界面和组件的标准发行版开始,我更喜欢从其“精简版”版本开始。 原因是因为我们打算直接使用相机,所以我们不想安装根本不会使用的软件,例如电子表格和文字处理器。 另外,最初,我希望直接使用Raspberry Pi Camera模块的“预览”模式,因为它也可以从命令行正常使用。 但是,我不得不在开发阶段修改这个角度,因为它与我决定用于该项目的框架不兼容。

Raspberry Pi Imager
Raspberry Pi成像仪

Not so long ago, people had to download first of all the right distribution archive and use additional software to “burn” the operating system on their SD cards. Luckily for us, the Raspberry Foundation has simplified much more the process through a neat tool, the Raspberry Pi Imager, that you can directly download from here.

不久前,人们必须首先下载正确的发行档案,然后使用其他软件在其SD卡上“刻录”操作系统。 对我们来说幸运的是,Raspberry Foundation通过一个简洁的工具Raspberry Pi Imager简化了更多流程,您可以从此处直接下载。

Simple UI for easy OS installation
简单的用户界面,易于安装操作系统

Once installed on your workstation (From PC to Mac and of course, Raspberry Pi), the installation procedure is painless as you’ll see.

一旦安装到工作站上(从PC到Mac,当然还有Raspberry Pi),安装过程将很轻松。

A custom install is required
需要自定义安装

First of all we need to choose the right distribution for our camera, so we’ll first choose the “Raspbery Pi OS Other” option from the main menu, followed by selecting the “Raspberry Pi OS Lite (32 Bits) : no desktop environment” choice. Once this is done, you can insert the SD Card to use in your system and select it from the tool’s drive chooser and you are then ready to it the “Write” button to start the process.

首先,我们需要为相机选择正确的发行版,因此我们首先要从主菜单中选择“ Raspbery Pi OS其他”选项,然后选择“ Raspberry Pi OS Lite(32位)”:无桌面环境“ 选择。 完成此操作后,您可以插入要在系统中使用的SD卡,然后从工具的驱动器选择器中选择它,然后准备使用“写入”按钮开始该过程。

Successful Burn
成功烧伤

It will take a bit of time to go through the writing and verification phases by the tool. Once this is done, your SD Cad is automatically ejected and you are ready to go… well almost. Indeed, as the access to the USB Port is limited, unless you want to start the installation process with an PiHQCam not fully assembled, we’ll be configuring its remote access.

该工具将花费一些时间来完成编写和验证阶段。 完成此操作后,您的SD Cad会自动弹出,您准备好了……差不多了。 实际上,由于对USB端口的访问受到限制,除非您要在未完全组装好PiHQCam的情况下开始安装过程,否则我们将配置其远程访问。

Boot partition mounted with success.
引导分区已成功安装。

Once you have popped back in your SD Card, the “boot” partition will be loaded in your system. To activate the remote access, open up a command-line terminal and gain access to the SD card drive’s location, such as the following for example on Mac, :

弹出SD卡后,“启动”分区将被加载到系统中。 要激活远程访问,请打开命令行终端并访问SD卡驱动器的位置,例如在Mac上,例如:

cd /Volumes/boot

cd /卷/启动

First of all, just create an empty file names “ ssh ” to enable remote SSH access from the first configuration boot of the Pi. You can do so by using the following command:

首先,只需创建一个空文件名“ ssh ”,即可从Pi的首次配置启动中启用远程SSH访问。 您可以使用以下命令来这样做:

touch ssh

触摸SSH

Now that the SSH access is done, we need to provide the Wi-Fi required information to the Pi, to gain access to our local network. To do so, create a new file “ wpa_supplicant.conf ”, still at the root of the “boot” partition, with the following command which will open up a new editor to insert the necessary Wi-Fi configuration:

现在已经完成了SSH访问,我们需要向Pi提供Wi-Fi所需的信息,以访问我们的本地网络。 为此,使用以下命令创建一个新文件“ wpa_supplicant.conf ”,该文件仍位于“ boot”分区的根目录下,该命令将打开一个新编辑器以插入必要的Wi-Fi配置:

nano wpa_supplicant.conf

纳米wpa_supplicant.conf

Below is an example of a configuration compatible with the current Buster Raspberry distribution:

以下是与当前的Buster Raspberry发行版兼容的配置示例:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

ctrl_interface = DIR = / var / run / wpa_supplicant GROUP = netdev

update_config=1

update_config = 1

country=FR

国家= FR

network={

网络= {

ssid=”MY-WIFI-NETWORK-SSID”

ssid =“ MY-WIFI-NETWORK-SSID”

psk=”MY-WIFI-NETWORK-PASSPHRASE”

psk =“ MY-WIFI-网络密码”

key_mgmt=WPA-PSK

key_mgmt = WPA-PSK

}

}

This is a simple configuration that of course you need to tune according to your own settings:

这是一个简单的配置,您当然需要根据自己的设置进行调整:

country: Choose the country code of your own country of course (FR, GB …);

国家 :选择您自己国家的国家代码(FR,GB…);

MY-WIFI-NETWORK-SSID: Enter here the SSID of your own Wi-Fi network;

MY-WIFI-NETWORK-SSID :在此处输入您自己的Wi-Fi网络的SSID;

MY-WIFI-NETWORK-PASSPHRASE: Enter here the secret passphrase / password to connect to your Wi-Fi network.

MY-WIFI-NETWORK-PASSPHRASE :在此处输入秘密密码/密码以连接到您的Wi-Fi网络。

Just exit the Nano editor (Ctrl-X, and Y to save the changes) to complete the configuration procedure. Of course, you can always edit these elements later on, once you are remotely connected to your Raspberry Pi.

只需退出Nano编辑器( 按Ctrl-XY保存更改)即可完成配置过程。 当然,一旦远程连接到Raspberry Pi,您以后就可以随时编辑这些元素。

Initial remote configuration completed.
初始远程配置已完成。

Just Before “ejecting” your SD Card, have a look at its boot partition to make sure that both files are there and ready for usage.

在“弹出” SD卡之前,请查看其引导分区,以确保两个文件都已存在并且可以使用。

Safely eject your SD card in order to prevent its corruption and insert it to the side of the screen enclosure of the project, before remounting it (or not) into the camera’s body part. Tweezers can be your best friends in these times, to insert and especially remove, the card, as well as handling the wired connection of the trackball.

为了防止其损坏,请安全弹出SD卡,然后将其插入(或不重新)安装到相机的身体部位,然后将其插入到项目屏幕外壳的侧面。 在这段时间里,镊子可以成为您最好的朋友,用于插入(尤其是取出)卡以及处理轨迹球的有线连接。

You’re ready to go, so go on, and power-up your Raspberry Pi!

您已经准备好出发,继续,为Raspberry Pi通电!

As it starts for the first time, you’ll see some LED blinking and the main screen powering up but … no image! Don’t worry! It is completely normal as the Raspberry Pi does not “see” yet the beautiful Pimoroni Hyperpixel Screen. We’ll come to this in a minute, but first, we need to continue the configuration part from the Pi itself.

第一次启动时,您会看到一些LED闪烁并且主屏幕正在启动,但是…没有图像! 不用担心 这是完全正常的,因为Raspberry Pi还没有“看到”漂亮的Pimoroni超像素屏幕。 我们待会儿会讲到这一点,但是首先,我们需要从Pi本身继续配置部分。

Still from your command-line terminal, try to connect after one minute to your Raspberry Pi over SSH. To do so, use the following command:

仍然从命令行终端,尝试在一分钟后通过SSH连接到Raspberry Pi。 为此,请使用以下命令:

ssh pi@raspberrypi.local

ssh pi@raspberrypi.local

Indeed, by default, this command should allow you to connect to any Pi that has its standard network configuration done (SSH enabled + Correct Wi-FI configuration). It is always a good thing to change its network hostname right away to avoid connecting to the “wrong” Pi on your network. May be, the first time you issue this command, you might have to add some network-related fingerprint to your local machine’s registry, which is quite standard procedure.

实际上,默认情况下,此命令应允许您连接到已完成其标准网络配置(启用SSH +正确的Wi-FI配置)的任何Pi。 立刻更改其网络主机名总是一件好事,以避免连接到网络上的“错误” Pi。 可能是,第一次发出此命令时,可能必须在本地计算机的注册表中添加一些与网络相关的指纹,这是非常标准的过程。

Standard SSH security warning.
标准SSH安全警告。

Once you are agreeing to do it, the SSH connection will require to enter the standard pi user’s password: “ raspberry ” (without the quotes of course). And upon hitting the right keys, you’ll gain remote access to the Raspberry Pi at the heart of your new Pi-Powered camera.

一旦您同意这样做,SSH连接将需要输入标准pi用户的密码:“ raspberry ”(当然不带引号)。 按下正确的键后,您将可以远程访问Raspberry Pi,它位于新的Pi供电相机的核心。

We’ll proceed first by ensuring that the Raspberry Pi has its software registry and local components all updated to the latest. In order to refresh the elements provided by the distribution, we’ll issue the following commands:

我们将首先确保Raspberry Pi的软件注册表和本地组件都已更新为最新版本。 为了刷新发行版提供的元素,我们将发出以下命令:

sudo apt-get update

sudo apt-get更新

sudo apt-get -y full-upgrade

sudo apt-get -y全面升级

The system will contact the official software repositories to update all software related information and will then proceed with the system’s full upgrade to the latest versions. This might take a bit of time, depending on your network connection and bandwidth. Once this is completed, we’ll install some basics tools with the command:

系统将联系官方软件存储库以更新所有与软件相关的信息,然后将系统完全升级到最新版本。 这可能需要一些时间,具体取决于您的网络连接和带宽。 完成此操作后,我们将使用以下命令安装一些基础工具:

sudo apt-get install -y vim git screen

sudo apt-get install -y vim git屏幕

vim: if you have seen few summers like me, you might me more used to edit text with this tool;

vim :如果您像我这样见过几个夏天,也许您会更习惯使用此工具编辑文本;

git: this is a software code utility that we’ll be needing later on;

git :这是一个软件代码实用程序,稍后我们将需要它;

screen: quite useful when performing task remotely on a pi, it creates a virtual environment, like a terminal, in which you can issue your commands and that, if your remote SSH session terminates, it will still hold the context and running commands together.

screen :在pi上远程执行任务时非常有用,它会创建一个虚拟环境(例如终端),您可以在其中发布命令,并且,如果远程SSH会话终止,它将仍然保留上下文并同时运行命令。

Now that we have to set some of the parameters required for the system to be fully secured and operational, through the use of the Raspberry configuration tool.

现在,我们必须通过使用Raspberry配置工具来设置使系统完全安全和可运行所需的一些参数。

sudo raspi-config

须藤raspi-config

Raspberry Configuration Tool Main Menu.
Raspberry配置工具主菜单。

Once the configuration interface is available, we need to change the following settings:

一旦配置界面可用,我们需要更改以下设置:

Hostname: in order to easily access the Raspberry over our network, it is better to give it a proper name, especially if you like me you have multiple Pis running on your LAN. So we can give it the following name “ picamera ”.

主机名 :为了方便地通过我们的网络访问Raspberry,最好给它起一个适当的名称,尤其是如果您喜欢我,您的LAN上有多个Pi。 因此,我们可以使用以下名称“ picamera ”。

Pi user password: as the default password is always the same for all Raspberry Pi, it is good (and safe) to change it to something more personal.

Pi用户密码 :由于所有Raspberry Pi的默认密码始终相同,因此将其更改为更个人的名称是很好(也是安全的)。

After changing some network parameter and security items, we are going now to activate few interfaces for our project to work:

更改了一些网络参数和安全性项目之后,我们现在要激活一些接口以使我们的项目正常工作:

PiCamera: of course, we need our camera to be activated to be able to take some nice shots, so better turn it on right now.

PiCamera :当然,我们需要激活相机才能拍摄出漂亮的照片,因此最好立即打开它。

I2C: this is the internal communication interface required by the trackball, so we also need to activate it.

I2C :这是轨迹球所需的内部通信接口,因此我们也需要激活它。

Advanced Options - Memory Split: as we are going to deal with high quality (and size) images, we need to give more “freedom” to the system to cope with them. Thus, we need to increase the memory split setting to “ 256 ”.

高级选项-内存分割 :当我们要处理高质量(和大尺寸)图像时,我们需要给系统更多的“自由度”以应对它们。 因此,我们需要将内存分割设置增加到“ 256 ”。

We are done now with the configurations, but DO NOT REBOOT just yet the Raspberry Pi as we have few more things we need to install.

现在我们已经完成了配置,但是请不要重新启动Raspberry Pi,因为我们还需要安装一些东西。

Pimoroni组件配置 (Pimoroni Components Configurations)

As our project relies on two great components from the Pimoroni Pirates (YARRHHH :), we are going to proceed right away with their configuration.

由于我们的项目依赖于Pimoroni Pirates(YARRHHH :)的两个重要组件,因此我们将立即进行其配置。

First of all, we need to install the library for the HyperPixel 4 Square screen to get some crisp image and visual interface for the project. They made it quite easy really through the use of a simple line command (that you can always split if you’d like to see what lies behind its magic):

首先,我们需要为HyperPixel 4 Square屏幕安装库,以获取项目的清晰图像和可视界面。 通过使用简单的line命令,它们确实非常容易(如果您想查看其魔术背后的含义,可以随时拆分):

curl https://get.pimoroni.com/hyperpixel4 | bash

卷曲https://get.pimoroni.com/hyperpixel4 | 重击

Installing Pimoroni’s HyperPixel Library
安装Pimoroni的HyperPixel库

It will fetch an interactive installation shell script that will ask you couple of questions, but that are fairly straight forward. You just need to confirm to proceed with the installation as well as choosing the model & configuration for the screen. As it is a one-line installer, it is able to cope with the right screen (Rectangular / Square) and Pi (PI4 and Others) models. For our project, we’ll choose the option 3, “ Weirdly Square - Pi 3B+ or older ” to match our own configuration with the A3+.

它将获取一个交互式安装外壳脚本,该脚本将询问您几个问题,但这很简单。 您只需要确认即可继续安装以及为屏幕选择型号和配置。 由于它是单行安装程序,因此能够处理正确的屏幕(矩形/正方形)和Pi(PI4和其他)模型。 对于我们的项目,我们将选择选项3Weirdly Square-Pi 3B +或更旧 ”,以将我们自己的配置与A3 +相匹配。

The installation process will take a little bit of time, depending on your bandwidth, but at its end, when being asked to reboot, say “ No ” as some additional steps will be required.

安装过程将花费一些时间,具体取决于您的带宽,但是最后,当要求重新启动时,请说“ ”,因为还需要一些其他步骤。

First, we need to edit the configuration file used during the boot sequence to add some extra screen parameters.

首先,我们需要编辑引导顺序中使用的配置文件,以添加一些额外的屏幕参数。

sudo nano /boon/config.txt

须藤nano /boon/config.txt

At the end of the file, add the following lines in order to power-off the screen’s backlight when shutting down:

在文件末尾,添加以下行,以便在关机时关闭屏幕的背光灯:

# Turn off the Hyperpixel Screen when shutting down

#关闭时关闭超像素屏幕

dtoverlay=gpio-poweroff,gpiopin=19,active_low=1

dtoverlay = gpio-poweroff,gpiopin = 19,active_low = 1

And we are done for the screen’s configuration so next time we’ll reboot, we’ll be able to see the Raspberry’s console on the screen directly.

屏幕配置已经完成,因此下次重新启动时,我们将能够直接在屏幕上看到Raspberry的控制台。

Now, before rebooting the Pi, we need to install the libraries required for the trackball’s control. There is also a single line command line available, however, I encountered some programming issues when using it, so I highly recommend you to use directly the GIT sources and build the library as the process is quite simple.

现在,在重新启动Pi之前,我们需要安装跟踪球控件所需的库。 还有一个单行命令行,但是,在使用它时遇到了一些编程问题,因此我强烈建议您直接使用GIT源并构建库,因为该过程非常简单。

First of all, we need to add some more python libraries to our system with the following command:

首先,我们需要使用以下命令将更多的python库添加到我们的系统中:

sudo apt-get install -y python3-pip python3-setuptools python3-dev python3-rpi.gpio python3-picamera

sudo apt-get install -y python3-pip python3-setuptools python3-dev python3-rpi.gpio python3-picamera

python3 -m pip install --upgrade --user Cython==0.29.10 pillow

python3 -m pip install --upgrade --user Cython == 0.29.10枕头

It will install the necessary Python 3 Libraries required for development as well as the picamera lib to access the HQ Camera Module from Python.

它将安装开发所需的必要Python 3库以及picamera库,以从Python访问HQ Camera Module。

The second command install additional required libraries for the Pimoroni’s trackball. We are now ready to perform the Trackball’s Library installation through the following set of commands:

第二个命令为Pimoroni的轨迹球安装其他必需的库。 现在,我们准备通过以下命令来执行轨迹球库的安装:

cd ~/Pimoroni

光盘〜/ Pimoroni

git clone https://github.com/pimoroni/trackball-python

git clone https://github.com/pimoroni/trackball-python

cd trackball-python

cd轨迹球-python

sudo ./install.sh

须藤./install.sh

Once it has finished cloning the code repository from Git, as well as performing the library’s installation, you can now finally reboot the Pi as all is ready to do some checkups.

一旦它完成了从Git克隆代码存储库以及执行库的安装,您现在就可以终于重新启动Pi了,因为一切都准备好进行一些检查。

sudo reboot

须藤重启

As you enter the command, you should see a first difference: indeed, the Raspberry Pi OS console is now visible on the HyperPixel screen, giving you some more clues on what is going on. When you get to the login prompt stage, connect back to your Pi over SSH, keeping in mind to change the hostname to what you defined earlier on. For example:

输入命令时,应该看到第一个区别:实际上,Raspberry Pi OS控制台现在可以在HyperPixel屏幕上看到,这为您提供了更多线索。 进入登录提示阶段时,请记住通过SSH重新连接到Pi,并将主机名更改为之前定义的名称。 例如:

ssh pi@picamera.local

ssh pi@picamera.local

Now that we know that the screen is working well, we might want to try the trackball as well. First of all, as the i2c port, used to connect the trackball to the screen is registered with a different ID, we need to temporarily create a link to it to use the Pimoroni’s examples.

既然我们知道屏幕运行良好,那么我们可能还想尝试一下轨迹球。 首先,由于用于将轨迹球连接到屏幕的i2c端口已使用不同的ID注册,因此我们需要临时创建指向该链接的链接,以使用Pimoroni的示例。

sudo ln -s /dev/i2c-3 /dev/i2c-1

须藤ln -s / dev / i2c-3 / dev / i2c-1

Now that our trackball is “visible” for the example, let’s put a bit of fun and color with the rainbow example:

现在示例中的轨迹球是“可见的”,让我们在彩虹示例中添加一些乐趣和色彩:

cd ~/Pimoroni/trackball-python/examples

cd〜/ Pimoroni / trackball-python / examples

python3 rainbow.py

python3 rainbow.py

You should now see your trackball lightning up with multiple colors. If this is not the case, you should be getting some useful error messages to try to find out what went wrong. May be check the polarity and connection between the screen and the trackball as the connection might be a bit loose if you haven’t extended sufficiently the pins soldered to the cable.

现在,您应该可以看到轨迹球以多种颜色闪烁。 如果不是这种情况,您应该收到一些有用的错误消息,以尝试找出问题所在。 可能要检查屏幕和轨迹球之间的极性和连接,因为如果您没有充分伸展焊接到电缆的插针,则连接可能会有点松动。

Go-gadgeto PiHQCamera (Go-go-gadgeto PiHQCamera)

项目源安装 (Project source installation)

Now that our system is ready and tested with its core components, we need to install some more libraries. One of them is Kivy, a really neat framework that I discovered when searching on how to build graphical interface without the use of the X standard environment. Kivy is using some custom configuration file to define the screens that are composing the application, offering multiple standard components, from media management to customized inputs. Going through all Kivy’s capabilities would take another full article, so I can only encourage you to browse their documentation and to take a walk through all the examples available ( https://kivy.org ).

现在我们的系统已经准备就绪并已通过其核心组件进行了测试,我们需要安装更多的库。 其中之一就是Kivy,这是一个非常整洁的框架,我在搜索如何在不使用X标准环境的情况下构建图形界面时发现了。 Kivy正在使用一些自定义配置文件来定义组成应用程序的屏幕,这些屏幕提供了从媒体管理到自定义输入的多个标准组件。 阅读所有Kivy的功能将花费另一篇完整的文章,因此,我只能鼓励您浏览他们的文档,并逐步浏览所有可用的示例( https://kivy.org )。

However, there are some issues with it, that are important to know about. I do not know if they are linked to the particular setup of the HyperPixel as I did not have the time to investigate more, but I wanted to share them with you as they will have an impact on the use of the project:

但是,有一些重要的问题需要了解。 我不知道它们是否与HyperPixel的特定设置相关联,因为我没有时间进行更多调查,但是我想与您分享它们,因为它们会对项目的使用产生影响:

Tab Panels “Impossible Touch” selection.
选项卡面板的“无法触摸”选择。

Tab Panels: the main interface is organized in 3 tabs (that we’ll go through later on). However, I could not get Kivy to allow “switching” between tabs by touch: I guess some internal event is not being raised properly as lots of SDL warning messages are being raised on the console. This is why the trackball comes to our rescue as scrolling left to right will trigger switching tabs.

标签面板 :主界面分为3个标签(稍后我们将介绍)。 但是,我无法让Kivy允许通过触摸在选项卡之间进行“切换”:我猜是由于控制台上引发了许多SDL警告消息,某些内部事件没有被正确引发。 这就是为什么跟踪球之所以能为我们提供帮助,是因为从左向右滚动将触发切换选项卡。

Menu selection might be tricky sometimes.
菜单选择有时可能很棘手。

Menus & Configuration fields: Kivy allows property management fairly easily really, however, still due to some SDL error message, “confirming choices in combo box might be a bit tricky and “prolonged” press on the screen might be necessary to validate file path or choosing the resolution of the pictures/movies.

菜单和配置字段 :Kivy确实可以相当轻松地进行属性管理,但是,仍然由于某些SDL错误消息,“在组合框中确认选择可能有些棘手,并且可能需要在屏幕上“长时间”按下以验证文件路径或选择图片/电影的分辨率。

Beside these points, that I hope to improve/fix in the future, this is quite a nice way to build fullscreen application on Raspberry.

除了这些要点之外,我希望将来可以改进/修复,这是在Raspberry上构建全屏应用程序的一种不错的方法。

Now, Kivy requires multiple libraries that are all installed with the following command:

现在,Kivy需要使用以下命令安装了多个库:

sudo apt install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev pkg-config libgl1-mesa-dev libgles2-mesa-dev libgstreamer1.0-dev git-core gstreamer1.0-plugins-{bad,base,good,ugly} gstreamer1.0-{omx,alsa} libmtdev-dev xclip xsel libjpeg-dev

sudo apt install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev pkg-config libgl1-mesa-dev libgles2-mesa-dev libgstreamer1.0-dev git-core gstreamer1.0-plugins- {坏,不好,好,丑} gstreamer1.0- {omx,alsa} libmtdev-dev xclip xsel libjpeg-dev

It will take some time again, so go ahead and grab a nice refreshing beverage ;)

这将需要一些时间,因此,继续并获取美味的清凉饮料;)

After the installation process is complete, we need to retrieve the project’s source code from GitHub:

安装过程完成后,我们需要从GitHub检索项目的源代码:

cd ~

光盘〜

git clone https://github.com/pierreyvesbaloche/PiHQCam.git

git clone https://github.com/pierreyvesbaloche/PiHQCam.git

cd PiHQCam

光盘PiHQCam

There is already also a first release so you can choose it if you’d prefer not to run the code from the streamline.

现在已经有了第一个版本,因此如果您不想从精简版中运行代码,则可以选择它。

Once the project’s directory is created we need to create a dedicated folder for our pictures and movies:

创建项目目录后,我们需要为图片和电影创建一个专用文件夹:

mkdir DCIM

mkdir DCIM

Also, to finish up the library’s installation, we perform one last dependencies installation:

另外,为了完成库的安装,我们执行最后一个依赖项安装:

pip3 install -r requirements.txt

pip3 install -r requirements.txt

Courage, we are almost set! We need now to add some specific configuration to the Kivy’s settings in order to get the HyperPixel Touch par working. To do so, we need to edit the main configuration file:

勇气,我们快完成了! 现在,我们需要在Kivy的设置中添加一些特定的配置,以使HyperPixel Touch参数正常工作。 为此,我们需要编辑主配置文件:

nano ~/.kivy/config.ini

纳米〜/ .kivy / config.ini

Once in it, locate the “ [input] ” section and replace it entirely with the following lines:

进入其中后,找到“ [input] ”部分,并将其完全替换为以下几行:

# Get the touchscreen to work with Kivy

#使触摸屏与Kivy配合使用

[input]

[输入]

mouse = mouse

鼠标=鼠标

mtdev_%(name)s = probesysfs,provider=mtdev

mtdev _%(name)s = probesysfs,provider = mtdev

hid_%(name)s = probesysfs,provider=hidinput

hid _%{name)s = probesysfs,provider = hidinput

# Review the calibration

#查看校准

[postproc:calibration]

[postproc:校准]

(mtdev) = xoffset=1,yoffset=1,xratio=-1,yratio=-1

(mtdev)= xoffset = 1,yoffset = 1,xratio = -1,yratio = -1

We are now ready to try out the PiHQCam project:

现在,我们准备尝试PiHQCam项目:

export PYTHONPATH=.

导出PYTHONPATH =。

python3 pihqcam/main.py

python3 pihqcam / main.py

The main interface will come up on your screen, directly with the camera view.

主界面将直接在摄像机视图中显示在屏幕上。

The PiHQCam project operational.
PiHQCam项目正在运行。

You can toggle the various vertical/horizontal panels by touch and navigate through the 3 main tabs with the left/right scroll of the trackball.

您可以通过触摸来切换各种垂直/水平面板,并使用轨迹球的向左/向右滚动浏览3个主选项卡。

We can now exit the program by scrolling to the far-right tab with the trackball then press the “ Quit ” button on the screen to perform the final stage of the installation.

现在,我们可以通过使用轨迹球滚动到最右侧的选项卡,然后按屏幕上的“ 退出 ”按钮来退出安装程序,以执行安装的最后阶段。

I have prepared a configuration service file in order to have the program startup automatically when the Pi starts, as we won’t be able to use any mouse or keyboards while on the go (hint : unless you set them up over bluetooth :). To enable this new service, simply enter the following commands:

我准备了一个配置服务文件,以便在Pi启动时自动启动程序,因为在旅途中我们将无法使用任何鼠标或键盘( 提示 :除非您通过蓝牙进行设置:)。 要启用此新服务,只需输入以下命令:

sudo cp etc/picamera.service /etc/systemd/system/

须藤cp etc / picamera.service / etc / systemd / system /

sudo systemctl enable picamera.service

sudo systemctl启用picamera.service

sudo systemctl start picamera.service

sudo systemctl启动picamera.service

sudo systemctl stop picamera.service

sudo systemctl stop picamera.service

It will copy the service definition file to the system’s location at first, then enable it for use. You can use the “ start ” command to launch the main application, ensuring that everything is ok, then stopping it with the last “ stop “ command.

它将首先将服务定义文件复制到系统位置,然后将其启用。 您可以使用“ 开始 ”命令启动主应用程序,确保一切正常,然后使用最后一个“ 停止 ”命令将其停止

Congratulations! You are now ready to use your Pi Powered HQ Camera!

恭喜你! 现在您可以使用Pi Powered HQ相机了!

PiHQCam GUI 演练 (PiHQCam GUI walkthrough)

As said earlier on, the interface is organized between panels, all allowing access to different settings & usage. Three main functionalities are represented by tabs on top of the screen: “ Camera ” Direct view from the camera, “ Browser ” for file access to medias and “ Info ” for access to information & configuration of the camera.

如前所述,该界面在面板之间进行组织,所有界面均允许访问不同的设置和用法。 屏幕顶部的选项卡代表三个主要功能:“ 摄像机 ”,可从摄像机直接查看,“ 浏览器 ”,用于访问媒体文件,“ 信息 ”,用于访问摄像机的信息和配置。

Camera Tab

相机标签

The Camera interface providing direct view for the camera when not capturing/filming. Originally, I had intended to use the PiCamera “preview” mode to have better visibility and performance while using it. However, and without getting too much into technical details, the use of Kivy window management and the camera preview, is not possible as the camera preview gets displayed “under” Kivy’s windows and I could not find any ways to solve it (transparent filling & Z-index, did not solved the issue….) Hopefully the next major revision of Kivy (actually 1.11.1) will be able to cope with this better. This is why I had to implement a custom preview mode, and then freezing the display when a picture or a video is taken.

相机界面可在不进行拍摄/拍摄时为相机提供直接视图。 最初,我打算使用PiCamera的“预览”模式,以便在使用时具有更好的可见性和性能。 但是,由于没有过多地了解技术细节,因此无法使用Kivy窗口管理和相机预览,因为相机预览显示在“ Kivy”窗口的下方,而且我找不到任何解决方法(透明填充和Z-index并没有解决问题……。)希望Kivy的下一个主要修订版(实际上是1.11.1)将能够更好地应对这一问题。 这就是为什么我必须实现自定义预览模式,然后在拍摄照片或视频时冻结显示的原因。

The camera preview tab.
相机预览选项卡。

Under the main camera preview, there are 3 buttons that allow you to choose from the different capture modes available:

在主摄像机预览下,有3个按钮,可让您从可用的不同捕获模式中进行选择:

Camera: Take a single shot right-away, when pressing once the trackball’s button.

相机 :按一下轨迹球的按钮后,立即拍摄一张照片。

Timer: Trigger a timer before taking the shot whose duration is configurable.

计时器 :在可设定持续时间的拍摄前触发计时器。

Video: Record with the camera when starting and stopping the sequence by pressing once the trackball for each segment.

视频 :在开始和停止序列时,通过按一下每个片段的轨迹球,用相机记录。

The left side of the screen also integrates an “Effects” panel that you can press on to reveal the set of available effects with the camera. Some of them are compatible with the direct view whereas others are not, so don’t be surprised. Simply touch the “View” panel to go back to the main camera preview screen.

屏幕的左侧还集成了“效果”面板,您可以按该面板以显示相机可用的一组效果。 其中一些与直接视图兼容,而另一些则与直接视图兼容,因此不要感到惊讶。 只需触摸“查看”面板即可返回到相机主预览屏幕。

Browser Tab

浏览器标签

The file browser tab.
文件浏览器选项卡。

The “Browser” tab points to the location configured (DCIM by default) where all the medias (pictures and videos) are stored. You can scroll between them with up & down rolls of the trackball which will update the preview of the media on the right-hand side (but give it some time to cope with big size images & movies :).

“浏览器”选项卡指向配置的位置(默认为DCIM),用于存储所有媒体(图片和视频)。 您可以在上下滚动轨迹球之间滚动它们,这将更新右侧的媒体预览(但请留出一些时间来处理大尺寸的图像和电影:)。

Under the preview, some basic information is available like the name, date, time & resolution in the “ Info ” panel.

在预览下,“ 信息 ”面板中提供了一些基本信息,例如名称,日期,时间和分辨率。

You can also perform some actions when revealing the “ Action ” panel under the preview. Currently, only the “ Delete ” option is available but additional features will come after.

当显示预览下方的“ 操作 ”面板时,您还可以执行一些操作。 当前,只有“ Delete ”选项可用,但还会有其他功能。

Info Tab

信息标签

The information & actions tab.
信息和操作标签。

The last “ Info ” tab allows you to reach the settings of the application, as well as either quitting the application or even shutting down completely the camera, so that you’ll be able to unplug the camera safely once the screen is completely turned off. You can define the following parameters:

最后一个“信息”标签可让您访问应用程序的设置,以及退出应用程序或什至完全关闭相机,这样,一旦屏幕完全关闭,您就可以安全地拔出相机的电源。 您可以定义以下参数:

Settings sub-menu.
设置子菜单。

Picture: where the medias are to be stored. A virtual keyboard will pop up for you to enter the path, or use a bluetooth keyboard to enter it with more ease.

图片 :要存储媒体的位置。 将会弹出一个虚拟键盘供您输入路径,或者使用蓝牙键盘更轻松地输入路径。

Thumbnails: where the thumbnails of the medias will be generated & stored.

缩略图 :媒体缩略图的生成和存储位置。

Timer: how long the timer should last before taking the shot.

计时器 :拍摄前计时器应持续多长时间。

Still Resolution: the resolution to be used for the *camera* & *timer* modes.

静止分辨率 :用于*相机*和*定时器*模式的分辨率。

Video Resolution: the resolution to be used for the *video* mode.

视频分辨率 :用于*视频*模式的分辨率。

现在去射击吧! (Now Go & Shoot!)

I know that the installation process might be a bit long, but this is nothing compared to the time spent in forums and Internet searches to get the “right” line of parameters to get it all to work. As this was my first Kivy based project, I have taken quite some “shortcuts” and I hope to be able to get back to it soon to improve its quality as well as set of features.

我知道安装过程可能会有点长,但这与在论坛和Internet搜索上获得“正确的”参数以使所有功能正常工作所花费的时间相比没有什么。 因为这是我第一个基于Kivy的项目,所以我已经采取了一些“捷径”,我希望能够尽快重新使用它,以提高其质量和功能集。

Indeed, like all Raspberry Pi projects, lots of the features integrated in the current version came during the design and development of it, as well as many mores that have filed up a backlog long enough to keep me busy for a while (…just need the time … ;).

确实,像所有Raspberry Pi项目一样,当前版本中集成的许多功能都是在其设计和开发过程中出现的,还有许多积压的积压时间足以让我忙一阵子(…仅需时间 … ;)。

Between the idea, the case’s 3D design, software coding & testing (with some hair tearing refactoring tasks too), it took me a fair amount of time to be able to share with you this project so I look forward to hear from you about how it went for you and to see some pictures of your creations. Have Fun !

在构思,案例的3D设计,软件编码和测试(还有一些令人毛骨悚然的重构任务)之间,我花了相当多的时间才能与您分享这个项目,因此,我期待着您的来信它适合您,并看到您的创作的一些图片。 玩得开心 !

翻译自: https://medium.com/@baloche.pierreyves/pihqcam-camera-oriented-software-ui-48cdb0d6c1b1

unity使ui面向镜头


http://www.taodudu.cc/news/show-4703576.html

相关文章:

  • Qml 中用 Shader 实现圣诞树旋转灯
  • CB:中国农大胡永飞组构建整合的鸡肠道微生物组的参考基因和基因组集
  • 哥本哈根诠释(Copenhagen Interpretation)
  • Cocos Creator | 通过 effect 实现卷轴展开和收拢效果
  • 评估数据,包括长度,角度,卷曲度
  • vue路由小妙招用法
  • 计算机网址登录教程,melogin.cn登录方法是什么
  • php 各种路由分析_thinkphp5路由详解
  • 公司开除并在离职证明上贬低被程序员怒怼,网友:总有耿直的员工
  • 苹果正在掀起一场战争!谷歌怒怼:你是舍不得自己的蛋糕!
  • 鏖战5小时,44对1,扎克伯格被参议员怒怼,结果他坐着就赚了28亿美元
  • 程序员初学者频繁使用count(*),被组长批评后怒怼:性能并不拉垮
  • 怒怼软件测测试不良培训机构!痛斥招转培!
  • 谷歌怒怼 iMessage 锁定 iPhone 用户,安卓用户受到同侪欺凌
  • vue 绑定多个class 顺便带上三元运算 判断
  • 解决wpsoffice for linux 退出后在后台驻留进程问题,顺便解决启动弹窗“Failed to open……From=Qing”报错
  • pip is not an internal or external command how to solve pip 不是内部或外部命令 ------解决方法 顺便把pip升级
  • 我在实验室电脑上玩Kali(中间人攻击、ARP,顺便断了同学的网)
  • kubernetes 禁用虚拟内存 swapoff -a ----- 顺便复习sed 命令
  • 论如何在 uni-app 上使用 sockjs 以及 stomp(顺便)
  • 顺便来看看~~
  • [业界] 关于诺基亚,上来吐槽两句埃洛普,顺便爆点料。
  • AutoHotkey实现大部分窗口隐藏标题栏,顺便透明些
  • 一不小心就中国区第一了,顺便说说感想
  • 由VB6.0的load窗体事件——看顺便学习法
  • 因为PPBC的防盗链,尝试用vba的对象来解决,顺便复习一下。。。
  • Python3.X识别混合编码,顺便解决“AttributeError: 'module' object has no attribute 'urlopen'”
  • 欧拉线性筛法求素数(顺便实现欧拉函数的求值)
  • rtsp 客户端请求视频的时候顺便填写输入用户名和密码的格式
  • 旅行app(游记、攻略、私人定制) | 顺便游旅行H5移动端实例

unity使ui面向镜头_pihqcam面向相机的软件ui相关推荐

  1. unity中3dUI或者模型始终面向摄像机,跟随摄像机视角旋转丨视角跟随丨固定视角

    视角跟随 本脚本为一个目标跟随 unity中3dUI或者模型始终面向摄像机,跟随摄像机视角旋转 使用方法超级简单,对于一个资深的Ctrl+cv程序极为友好 不多讲解直接上代码 代码模块 public ...

  2. 面向表开发 面向服务开发_面向繁忙开发人员的计算机视觉

    面向表开发 面向服务开发 This article is part of a series introducing developers to Computer Vision. Check out o ...

  3. 面向spi和面向api_面向API的设计的重要性

    面向spi和面向api Many programmers (or coders, or software engineers, or computer wizards, or whatever ter ...

  4. 面向服务的面向业务基础

    面向服务的面向业务基础 发布日期: 2007-07-12 | 更新日期: 2007-07-12 Ulrich Homann Microsoft Corporation 适用于: 企业体系结构 面向服务 ...

  5. 面向业务和面向硬件编程

    计算机程序设计思想越来越有意思,充满了哲学的味道,今天总结下分层的设计优化思想:最上层面向业务.和最底层面向硬件. 面向业务编程 面向业务编程,就好比样本决定算法(数据工程师),而不是拿模型套问题(机 ...

  6. 面向过程、面向函数、面向对象的区别浅谈

    Python的面向过程.面向函数.面向对象的区别浅谈 转自--猎奇古今,加上其他 有人之前私信问我,python编程有面向过程.面向函数.面向对象三种,那么他们区别在哪呢? 面向过程就是将编程当成是做 ...

  7. 【软件构造】面向正确性和健壮性的软件构造小记

    本文介绍了面向正确性和健壮性的软件构造,介绍了健壮性和正确性,以及MTBF和MTTF,最后重点介绍了Error和Exception 文章目录 一.什么是健壮性和正确性? 1.健壮性 2.正确性 3.正 ...

  8. 【游戏开发实战】Unity使用ShaderGraph制作一个Loading水球(能量球 | UI | 2D | 特效 | URP)

    文章目录 一.前言 二.ShaderGraph入门 三.ShaderGraph制作2D Loading水球 1.创建Unlit Shader Graph 2.创建一个圆 3.从下到上填充的效果 4.填 ...

  9. 面向物联网的 23 个开源软件项目

    物联网市场呈现碎片化.无定形.不断变化的特点,其性质需要不仅仅像平常那样关注互操作性.开源在这方面表现不俗也就不足为奇了--客户犹豫不决,不敢将物联网的未来寄托在一种可能销声匿迹或变得难以定制.互联的 ...

最新文章

  1. python中一共有多少个关键字-Python中有几个关键字
  2. Problem A: 素数对
  3. jq 选择多个子元素,,添加,删除多个类
  4. Lie to me不错
  5. 天池 在线编程 能否转换
  6. python 字符串replace函数_01-Python里字符串的常用操作方法--replace()函数
  7. shell mysql 取值_shell 脚本中获取mysql多个字段的值
  8. 基于 MVP + Glide + Retrofit + RxJava2.0 + butterknife 的C9MJ TV App
  9. php 图像居中裁剪函数,php中自定义图像居中裁剪函数实现的代码案例
  10. 用计算机画画内容,【经验】怎么用电脑绘画?
  11. 炫龙炎魔T1笔记本 Win7 系统安装
  12. 将think-installer类库“v1.0.0“更新到“v2.0.0“
  13. 微信二维码来源统计自动生成二维码统计?
  14. linux与信息安全,网络与信息安全系统安全Linux系统安全.ppt
  15. 解决网页在浏览器有反应 在手机端没反应问题
  16. getTime()获取时间戳方法与时区有关
  17. Git的学习之路02 Git的工作流程、工作区、暂存区、版本库及创建版本库
  18. 计算机专业怎么防止脱发,电脑工作者如何防止脱发出现
  19. 12、手机归属地查询API接口,免费好用
  20. 甲虫之王怀旧服新开的服务器是否自动开门,魔兽世界怀旧服:千人转到未开门服务器,会诞生千只甲虫之王吗?...

热门文章

  1. Head First (1) - 春江水暖鸭先知
  2. Unity Serialize总结
  3. dtree.js菜单列表加密,实现Code
  4. 天津室内设计培训班:0基础必知的5个室内设计原则
  5. 关于正当防卫的几个案例分析
  6. 入门知识(二)WPF所有的画刷工具
  7. 云原生k8s的前世今生--Docker
  8. 第八章 数组 个人总结笔记
  9. 仓库管理系统软件哪个好
  10. 数字图像学笔记——14. 图像退化与复原(线性退化)