Difference between revisions of "Template:FriendlyDesktop-Contents"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
 
(14 intermediate revisions by the same user not shown)
Line 35: Line 35:
 
For example, the transformation scaling horizontal coordinates by 0.8, vertical coordinates by 1.04 and moving the screen by 35 pixels right and 19 pixels down:  
 
For example, the transformation scaling horizontal coordinates by 0.8, vertical coordinates by 1.04 and moving the screen by 35 pixels right and 19 pixels down:  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
xrandr --output HDMI1 --transform 0.80,0,-35,0,1.04,-19,0,0,1
+
xrandr --output HDMI-1 --transform 0.80,0,-35,0,1.04,-19,0,0,1
 
</syntaxhighlight>
 
</syntaxhighlight>
 
====Automatic adjustment at boot====
 
====Automatic adjustment at boot====
Line 69: Line 69:
 
===4K Video Playing===
 
===4K Video Playing===
 
====Play with Qt Player with Hardware Decoding====
 
====Play with Qt Player with Hardware Decoding====
FriendlyDesktop has integrated a Qt5-VideoPlayer utility. This utility has support for Rockchip's gstreamer plug-in and supports 4K video playing with hardware decoding. You can start it by following the steps below:
+
FriendlyDesktop has integrated a [https://github.com/friendlyarm/rk-player-qt Qt5-VideoPlayer] utility. This utility has support for Rockchip's gstreamer plug-in and supports 4K video playing with hardware decoding. You can start it by following the steps below:
 
On FriendlyDesktop's main window open "Sound & Video" and click on "Qt5-VideoPlayer".<br />
 
On FriendlyDesktop's main window open "Sound & Video" and click on "Qt5-VideoPlayer".<br />
 
<br />
 
<br />
 
On the player's main window click on the bottom left's "Open" button to load a video file and double-click on its name on the file list to start video playing. Here is how it looks like. You can set the display window to full screen and adjust the volume:<br />
 
On the player's main window click on the bottom left's "Open" button to load a video file and double-click on its name on the file list to start video playing. Here is how it looks like. You can set the display window to full screen and adjust the volume:<br />
 
[[File:Friendlydesktop-player.jpg|frameless|480px]]<br />
 
[[File:Friendlydesktop-player.jpg|frameless|480px]]<br />
 +
Qt5-VideoPlayer source code: https://github.com/friendlyarm/rk-player-qt<br />
  
 
====Play with Linux Command====
 
====Play with Linux Command====
Line 83: Line 84:
  
 
===Work with USB Camera===
 
===Work with USB Camera===
Connect a USB camera e.g. Logitech C270/C920 to a board that runs FriendlyDesktop. After your system is booted click on the "Other" menu option in the main window to start "xawtv" and you will be able to preview with this camera.
+
Insert the USB camera (such as Logitech C270/C920) into the development board. Double click the "USB Camera" icon on desktop will pop up the luvcview gui (need to use the 2019/05/11+ version firmware). <br />
 +
the luvcview tool is an open source software that you can compile yourself:<br />
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/ksv1986/luvcview
 +
cd luvcview
 +
make
 +
</syntaxhighlight>
 +
View the usage of luvcview:
 +
<syntaxhighlight lang="bash">
 +
./luvcview -h
 +
</syntaxhighlight>
 +
Parameter Description:
 +
<syntaxhighlight lang="bash">
 +
luvcview version 0.2.1
 +
Usage: uvcview [-h -d -g -f -s -i -c -o -C -S -L -l -r]
 +
-h print this message
 +
-d /dev/videoX use videoX device
 +
-g use read method for grab instead mmap
 +
-w disable SDL hardware accel.
 +
-f video format default jpg others options are yuv jpg
 +
-i fps use specified frame interval
 +
-s widthxheight use specified input size
 +
-c enable raw frame capturing for the first frame
 +
-C enable raw frame stream capturing from the start
 +
-S enable raw stream capturing from the start
 +
-o avifile create avifile, default video.avi
 +
-L query valid video formats
 +
-l query valid controls and settings
 +
-r read and set control settings from luvcview.cfg
 +
</syntaxhighlight>
 +
To preview USB camera (640x360@30fps),  you can use the following command:
 +
<syntaxhighlight lang="bash">
 +
./luvcview -d /dev/video8 -i 30 -s 640x360
 +
</syntaxhighlight>
 +
As you can see from the output of luvcview, hardware acceleration has been turned on:
 +
<syntaxhighlight lang="bash">
 +
pi@NanoPC-T4:/etc/xrdp$ luvcview -d /dev/video8 -i 30 -s 640x360
 +
luvcview version 0.2.1
 +
interval: 30 fps
 +
Hardware acceleration available
 +
video /dev/video8
 +
</syntaxhighlight>
  
 
===File Transfer with Bluetooth===
 
===File Transfer with Bluetooth===
Line 90: Line 132:
  
 
===Install OpenCV===
 
===Install OpenCV===
On FriendlyDesktop's main window click on System Tools -> Terminator to open a commandline utility and run the following commands to install OpenCV 3.4:
+
OpenCV has been pre-installed in FriendlyCore/FriendlyDesktop (Version after 201905) and does not require manual installation.<br />
<syntaxhighlight lang="bash">
+
Please refre this link: https://github.com/friendlyarm/install-opencv-on-friendlycore/blob/rk3399/README.md
su -
+
cd /root/
+
git clone https://github.com/friendlyarm/install-opencv-on-friendlycore
+
cd install-opencv-on-friendlycore
+
./install-opencv.sh
+
cp examples/cv-env.sh /usr/bin/
+
</syntaxhighlight>
+
After installation is done compile it and test it by running a facial recognition test case:
+
<syntaxhighlight lang="bash">
+
su -
+
cd /usr/local/share/OpenCV/samples/cpp
+
g++ -ggdb facedetect.cpp -o facedetect `pkg-config --cflags --libs /usr/local/lib/pkgconfig/opencv.pc`
+
. setqt5env
+
./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_eye.xml" --scale=1.3 /usr/local/share/OpenCV/samples/data/data/lena.jpg
+
</syntaxhighlight>
+
Here is how it looks like:<br />
+
[[File:Friendlydesktop-opencv.png|frameless|480px]]
+
  
 
===Develop Qt Applications===
 
===Develop Qt Applications===
 
FriendlyDesktop has a Qt 5.10.0 which supports RK3399's OpenGL ES and Gstreamer 1.0 hardware acceleration and a QtCreator IDE which is ready  and can be used to compile and run applications. Here is how it looks like:<br />
 
FriendlyDesktop has a Qt 5.10.0 which supports RK3399's OpenGL ES and Gstreamer 1.0 hardware acceleration and a QtCreator IDE which is ready  and can be used to compile and run applications. Here is how it looks like:<br />
 
[[File:friendlydesktop-qtcreator.png|500px]]<br />
 
[[File:friendlydesktop-qtcreator.png|500px]]<br />
 +
When running the Qt app, you need to specify the platform parameter to xcb as follows:
 +
<syntaxhighlight lang="bash">
 +
./HelloQt --platform xcb
 +
</syntaxhighlight>
  
 
===WiringPi and Python Wrapper===
 
===WiringPi and Python Wrapper===
Line 119: Line 148:
  
 
===Switch audio default output device===
 
===Switch audio default output device===
====Set the default output device ====
+
====View the current default output device====
Edit the file /etc/pulse/default.pa and change the value of set-default-sink. When the value is 0, it means sound will output to HDMI, and 1 means it sound will output to the headphone jack, as shown below:
+
On the terminal of the non-root user, enter the following command:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
set-default-sink 0
+
pactl info -vvv
 +
</syntaxhighlight>
 +
The information displayed contains the following, indicating that the current audio output is directed to the headset:
 +
<syntaxhighlight lang="bash">
 +
Default Sink: alsa_output.platform-rt5651-sound.stereo-fallback
 +
</syntaxhighlight>
 +
The information displayed contains the following, indicating that the current audio output is to HDMI:
 +
<syntaxhighlight lang="bash">
 +
Default Sink: alsa_output.platform-hdmi-sound.stereo-fallback
 +
</syntaxhighlight>
 +
====Set headphone jack as the default output device====
 +
On the terminal of the non-root user, enter the following command:
 +
<syntaxhighlight lang="bash">
 +
pactl set-default-sink alsa_output.platform-rt5651-sound.stereo-fallback
 +
</syntaxhighlight>
 +
Set default volume to 20%:
 +
<syntaxhighlight lang="bash">
 +
pactl -- set-sink-volume alsa_output.platform-rt5651-sound.stereo-fallback 20%
 +
</syntaxhighlight>
 +
====Set hdmi as the default output device====
 +
On the terminal of the non-root user, enter the following command:
 +
<syntaxhighlight lang="bash">
 +
pactl set-default-sink  alsa_output.platform-hdmi-sound.stereo-fallback
 +
</syntaxhighlight>
 +
==== View settings have taken effect ====
 +
<syntaxhighlight lang="bash">
 +
cat /var/lib/pulse/*-default-sink
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 128: Line 183:
 
This method is only valid for the current playback process: <br />
 
This method is only valid for the current playback process: <br />
 
Open the menu "Sound & Video" -> "PulseAudio Volume Control", click the "Built-in Audio Stereo" button on the interface to switch between different output devices, such as switching between HDMI and headphone jack.
 
Open the menu "Sound & Video" -> "PulseAudio Volume Control", click the "Built-in Audio Stereo" button on the interface to switch between different output devices, such as switching between HDMI and headphone jack.
 
===Disable system automatic sleep ===
 
Open a command line terminal and enter the following command:
 
<syntaxhighlight lang="bash">
 
xset s off
 
xset -dpms
 
</syntaxhighlight>
 
  
 
===Play RTSP video stream (or IP Camera) ===
 
===Play RTSP video stream (or IP Camera) ===
Line 143: Line 191:
 
Change the address after rtsp:// to the real address.
 
Change the address after rtsp:// to the real address.
  
 +
===Chromium web browser ===
 +
Chromium web browser has enabled hardware acceleration by default, supports WebGL, and can view hardware acceleration details by entering the URL chrome://gpu, as shown below:<br />
 +
[[File:Chromium-gpu.png|frameless|400px]]
  
<!--
+
===Screen saver and auto sleep related settings ===
===取消自动登录===
+
The screen saver configuration file is /etc/xdg/autostart/xset_command.desktop. The default factory settings are that the screen saver and DPMS are both closed. You can change the configuration by modifying this file.
TODO
+
 
===性能相关设置===
+
===Install Scratch===
TODO
+
enter the following command:
===电源管理===
+
<syntaxhighlight lang="bash">
TODO
+
sudo apt-get install scratch:arm64
===定时开关机===
+
</syntaxhighlight>
TODO
+
 
===串口助手===
+
===Install Arduino IDE===
TODO
+
enter the following command:
===使用NVME SSD固态硬盘===
+
<syntaxhighlight lang="bash">
TODO
+
sudo apt-get install arduino:arm64
===WIFI AP===
+
</syntaxhighlight>
TODO
+
 
===蓝牙键盘===
+
===Start the program automatically at startup===
TODO
+
Put the desktop file in the ~/.config/autostart/ directory, for example:
===4G网络===
+
<syntaxhighlight lang="bash">
TODO
+
cp /usr/share/applications/org.qt-project.qtcreator.desktop ~/.config/autostart/
===USB WIFI===
+
</syntaxhighlight>
TODO
+
 
===USB摄像头===
+
===Login to the desktop as the root user===
TODO
+
Edit the /root/.profile file:
-->
+
<syntaxhighlight lang="bash">
 +
sudo vim /root/.profile
 +
</syntaxhighlight>
 +
Replace with the following:
 +
<syntaxhighlight lang="bash">
 +
if [ -n "$BASH_VERSION" ]; then
 +
    if [ -f "$HOME/.bashrc" ]; then
 +
. "$HOME/.bashrc"
 +
    fi
 +
fi
 +
if [ -d "$HOME/bin" ] ; then
 +
    PATH="$HOME/bin:$PATH"
 +
fi
 +
</syntaxhighlight>
 +
Run the following command to modify the lightdm configuration file and change the automatically logged-in user name to root:
 +
<syntaxhighlight lang="bash">
 +
sudo sed -i 's/autologin-user=pi/autologin-user=root/g' /usr/share/lightdm/lightdm.conf.d/20-defaultsession.conf
 +
</syntaxhighlight>
 +
Run the reboot command to restart:
 +
<syntaxhighlight lang="bash">
 +
sudo reboot
 +
</syntaxhighlight>
 +
If you want to log in, the desktop icons and configuration are the same as the pi user, you can copy the relevant directory from the /home/pi directory:
 +
<syntaxhighlight lang="bash">
 +
sudo rm -rf /root/Desktop /root/Pictures /root/.config
 +
sudo cp -af /home/pi/Desktop /home/pi/Pictures /home/pi/.config /root/
 +
sudo chown root:root /root/Desktop /root/Pictures /root/.config
 +
</syntaxhighlight>

Latest revision as of 06:54, 12 December 2022

1 Account & Password

Regular Account:

   User Name: pi
   Password: pi

Root:

   User Name: root
   Password: fa

2 WiFi Connection

Click on the icon on the top right in the FriendlyDesktop's main window, select your wanted WiFi hotspot and proceed with prompts

3 HDMI/DP LCD Resolution

Open the system's menu and go to Perferences -> Monitor Settings to customize your settings.
Recommended resolution: 1920x1080@60Hz

4 Adjust HDMI overscan

Open the command line terminal and enter the command to operate, Note:
1) You need to login to the desktop;
2) If you are using ssh terminal, please use the same username as the desktop login. The default is pi. You cannot use the root user. you also need to assign the DISPLAY variable:

export DISPLAY=:0.0

4.1 Query which resolutions the display supports

xrandr -q

4.2 Set resolution

For example set to 1920X1080@60Hz:

xrandr --output HDMI-1 --mode 1920x1080 --refresh 60

4.3 Adjust the HDMI overscan

For example, the transformation scaling horizontal coordinates by 0.8, vertical coordinates by 1.04 and moving the screen by 35 pixels right and 19 pixels down:

xrandr --output HDMI-1 --transform 0.80,0,-35,0,1.04,-19,0,0,1

4.4 Automatic adjustment at boot

Edit ~/.config/autostart/lxrandr-autostart.desktop,Write the full xrandr command to the key at the beginning of "Exec= as shown below:

[Desktop Entry]
Type=Application
Name=LXRandR autostart
Comment=Start xrandr with settings done in LXRandR
Exec=sh -c 'xrandr --output HDMI-1 --mode 1920x1080 --refresh 50 --transform 1.04,0,-35,0,1.05,-30,0,0,1'
OnlyShowIn=LXDE

5 eDP LCD Display Rotation

If you want to rotate an eDP LCD's display you can do it by commanding "xrotate.sh" to rotate its display to 90/180/270 degrees. You can rotate display clockwise by 90 degrees by running the following command as root. This command calls lightdm to make your change effective immediately:

sudo xrotate.sh -m CW -r

For more details about its options you can run "xrotate -h".
Note: this command doesn't support HDMI display's rotation. If you want to rorate an HDMI's display you need to refer to X11's tech documents and make changes in "/etc/X11/xorg.conf".

Note: when you play a video with hardware decoding your player's display window doesn't rotate with your LCD's display

6 Test OpenGL ES

You can test it by clicking on the Terminator icon to start a commandline utility in the System Tools and run the following commands:

taskset -c 4-5 glmark2-es2

Friendlydesktop-glmark-es.png
Friendlydesktop-glmark-es2-score.jpg

7 4K Video Playing

7.1 Play with Qt Player with Hardware Decoding

FriendlyDesktop has integrated a Qt5-VideoPlayer utility. This utility has support for Rockchip's gstreamer plug-in and supports 4K video playing with hardware decoding. You can start it by following the steps below: On FriendlyDesktop's main window open "Sound & Video" and click on "Qt5-VideoPlayer".

On the player's main window click on the bottom left's "Open" button to load a video file and double-click on its name on the file list to start video playing. Here is how it looks like. You can set the display window to full screen and adjust the volume:
Friendlydesktop-player.jpg
Qt5-VideoPlayer source code: https://github.com/friendlyarm/rk-player-qt

7.2 Play with Linux Command

You can play it by running the following command in a commandline utility:

gst-player.sh

By default its voice will be output to audio jack. You can locate this script by commanding "which gst-player.sh". You can customize its behavior by making changes in this script.

8 Work with USB Camera

Insert the USB camera (such as Logitech C270/C920) into the development board. Double click the "USB Camera" icon on desktop will pop up the luvcview gui (need to use the 2019/05/11+ version firmware).
the luvcview tool is an open source software that you can compile yourself:

git clone https://github.com/ksv1986/luvcview
cd luvcview
make

View the usage of luvcview:

./luvcview -h

Parameter Description:

luvcview version 0.2.1
Usage: uvcview [-h -d -g -f -s -i -c -o -C -S -L -l -r]
-h print this message
-d /dev/videoX use videoX device
-g use read method for grab instead mmap
-w disable SDL hardware accel.
-f video format default jpg others options are yuv jpg
-i fps use specified frame interval
-s widthxheight use specified input size
-c enable raw frame capturing for the first frame
-C enable raw frame stream capturing from the start
-S enable raw stream capturing from the start
-o avifile create avifile, default video.avi
-L query valid video formats
-l query valid controls and settings
-r read and set control settings from luvcview.cfg

To preview USB camera (640x360@30fps), you can use the following command:

./luvcview -d /dev/video8 -i 30 -s 640x360

As you can see from the output of luvcview, hardware acceleration has been turned on:

pi@NanoPC-T4:/etc/xrdp$ luvcview -d /dev/video8 -i 30 -s 640x360
luvcview version 0.2.1
 interval: 30 fps
Hardware acceleration available
video /dev/video8

9 File Transfer with Bluetooth

Click on the "Preferences" in the main window's menu to start Bluetooth Manager and click on "Search" to search surrounding Bluetooth devices. Click on your wanted device, pair the device with your board and you will be able to do file transfer, here is how it looks like:
Friendlydesktop-ble-sendfile.jpg

10 Install OpenCV

OpenCV has been pre-installed in FriendlyCore/FriendlyDesktop (Version after 201905) and does not require manual installation.
Please refre this link: https://github.com/friendlyarm/install-opencv-on-friendlycore/blob/rk3399/README.md

11 Develop Qt Applications

FriendlyDesktop has a Qt 5.10.0 which supports RK3399's OpenGL ES and Gstreamer 1.0 hardware acceleration and a QtCreator IDE which is ready and can be used to compile and run applications. Here is how it looks like:
Friendlydesktop-qtcreator.png
When running the Qt app, you need to specify the platform parameter to xcb as follows:

./HelloQt --platform xcb

12 WiringPi and Python Wrapper

13 Switch audio default output device

13.1 View the current default output device

On the terminal of the non-root user, enter the following command:

pactl info -vvv

The information displayed contains the following, indicating that the current audio output is directed to the headset:

Default Sink: alsa_output.platform-rt5651-sound.stereo-fallback

The information displayed contains the following, indicating that the current audio output is to HDMI:

Default Sink: alsa_output.platform-hdmi-sound.stereo-fallback

13.2 Set headphone jack as the default output device

On the terminal of the non-root user, enter the following command:

pactl set-default-sink  alsa_output.platform-rt5651-sound.stereo-fallback

Set default volume to 20%:

pactl -- set-sink-volume alsa_output.platform-rt5651-sound.stereo-fallback 20%

13.3 Set hdmi as the default output device

On the terminal of the non-root user, enter the following command:

pactl set-default-sink  alsa_output.platform-hdmi-sound.stereo-fallback

13.4 View settings have taken effect

cat /var/lib/pulse/*-default-sink

13.5 Temporary switching during playback

This method is only valid for the current playback process:
Open the menu "Sound & Video" -> "PulseAudio Volume Control", click the "Built-in Audio Stereo" button on the interface to switch between different output devices, such as switching between HDMI and headphone jack.

14 Play RTSP video stream (or IP Camera)

Open a command line terminal and enter the following command:

gst-launch-1.0 rtspsrc location="rtsp://admin:12345@192.168.1.120:554/live/main" ! rtph264depay ! decodebin ! rkximagesink

Change the address after rtsp:// to the real address.

15 Chromium web browser

Chromium web browser has enabled hardware acceleration by default, supports WebGL, and can view hardware acceleration details by entering the URL chrome://gpu, as shown below:
Chromium-gpu.png

16 Screen saver and auto sleep related settings

The screen saver configuration file is /etc/xdg/autostart/xset_command.desktop. The default factory settings are that the screen saver and DPMS are both closed. You can change the configuration by modifying this file.

17 Install Scratch

enter the following command:

sudo apt-get install scratch:arm64

18 Install Arduino IDE

enter the following command:

sudo apt-get install arduino:arm64

19 Start the program automatically at startup

Put the desktop file in the ~/.config/autostart/ directory, for example:

cp /usr/share/applications/org.qt-project.qtcreator.desktop ~/.config/autostart/

20 Login to the desktop as the root user

Edit the /root/.profile file:

sudo vim /root/.profile

Replace with the following:

if [ -n "$BASH_VERSION" ]; then
    if [ -f "$HOME/.bashrc" ]; then
	. "$HOME/.bashrc"
    fi
fi
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

Run the following command to modify the lightdm configuration file and change the automatically logged-in user name to root:

sudo sed -i 's/autologin-user=pi/autologin-user=root/g' /usr/share/lightdm/lightdm.conf.d/20-defaultsession.conf

Run the reboot command to restart:

sudo reboot

If you want to log in, the desktop icons and configuration are the same as the pi user, you can copy the relevant directory from the /home/pi directory:

sudo rm -rf /root/Desktop /root/Pictures /root/.config
sudo cp -af /home/pi/Desktop /home/pi/Pictures /home/pi/.config /root/
sudo chown root:root /root/Desktop /root/Pictures /root/.config