Face Tracking
Our face detection uses Tencent's ncnn, uses the SP7021 PWM module for servo control, and rootfs uses the image of the Raspberry Pi.
Configure the kernel
We need to use PWM, so the kernel enables PWM driver, set the right pins in DTS。
Enable the PWM driver
plus1@ubuntu:~/SP7021_4.19/linux/kernel$ make menuconfig
Device Drivers->Pulse-Width Modulation (PWM) Support->SP7021 PWM support
Configure the output pin of pwm in dts
linux/kernel/arch/arm/boot/dts/sp7021-common.dtsi
modify the pwm device node,
pwm: pwm@0x9c007a00 {
#pwm-cells = <2>;
compatible = "sunplus,sp7021-pwm";
reg = <0x9c007a00 0x80>;
clocks = <&clkc DISP_PWM>;
resets = <&rstc RST_DISP_PWM>;
};
add the pin contrl information,
pwm: pwm@0x9c007a00 {
#pwm-cells = <2>;
compatible = "sunplus,sp7021-pwm";
reg = <0x9c007a00 0x80>;
clocks = <&clkc DISP_PWM>;
resets = <&rstc RST_DISP_PWM>;
pinctrl-names = "defalut";
pinctrl-0 = <&pins_pwm0>;
};
seach the pctl device node,
pctl: pctl@0x9C000100 {
compatible = "sunplus,sp7021-pctl";
reg = <0x9C000100 0x100>, <0x9C000300 0x80>, <0x9C000380 0x80>, <0x9C0032e4 0x1C>, <0x9C000080 0x20>;
gpio-controller;
#gpio-cells = <2>;
interrupt-parent = <&intc>;
interrupts =
<120 IRQ_TYPE_LEVEL_HIGH>,
<121 IRQ_TYPE_LEVEL_HIGH>,
<122 IRQ_TYPE_LEVEL_HIGH>,
<123 IRQ_TYPE_LEVEL_HIGH>,
<124 IRQ_TYPE_LEVEL_HIGH>,
<125 IRQ_TYPE_LEVEL_HIGH>,
<126 IRQ_TYPE_LEVEL_HIGH>,
<127 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clkc GPIO>;
resets = <&rstc RST_GPIO>;
pins_uart0: pins_uart0 {
sppctl,groups = "UA0";
sppctl,function = "UA0";
};
we use the 8, 9 pin for the pwm output pin, add the pwm pin mux information into the pctl node.
The 8,9 pin in the demo board v3.
Now how th compile source code ,please refer:How to build and install SP7021 Linux image to run Raspbian on SD card .
Install related components
in the raspbian ubuntu, install the camke and libopencv-dev
Download ncnn source code
download the attachment file ,the attachment file is the face tracking demo code.
Unzip the file to ncnn/example