Head tracking module for Godot game engine, using OpenCV with GPU support.

godot-opencv-gpu-perspective

This is a simple demonstration of using OpenCV to track the head of the user from the web cam, and adjusting the camera's position and angle accordingly in the 3d environment in Godot; giving a feeling of perspective to the user when they move their head. You can find several examples of this concept on the internet.

The problem with this concept is that detecting the position of the face in a frame, using the CPU can be slow and the user can experience lag when moving their head. Therefore in this code I have used the GPU module of OpenCV which uses CUDA to process each frame using Haar cascades. It is still not perfect, but compared to using the CPU it is significantly better.

Dependencies

This is a module written for the Godot engine, which can be found here.

You need to have a recent version of OpenCV which was compiled with GPU support.

The GPU module of OpenCV is implemented using Nvidia's CUDA so unfortunately you are going to need a CUDA compatible GPU.

I have OpenCV 2.4.10 which I built with CUDA 6.5. I'm using the proprietary Nvidia driver 340.65 on Debian GNU/Linux. I had problems when I tried to build OpenCV with older versions of CUDA so be adviced.

You can find more information about the OpenCV GPU module here.

Usage

Copy the cvperspective folder into the modules directory under the Godot engine's root directory. Compile Godot as usual, open the example project included in the example_project directory.

Note: The code uses haar cascades to detect the position of the face. The path to the xml file for the cascade should be specified correctly in the OpenCVPerspective.cpp file.

When the start() function is called in Godot, a new thread is created which connects to the web cam and gets the detected face's position each frame. Using the get_horizontal_offset() and get_vertical_offset() functions, you can get the offset of the user's head from the middle of the screen for the latest processed frame. Using the offset values, you can modify the camera's transform values accordingly.

Similar Resources

K6 extension that adds support for browser automation and end-to-end web testing using playwright-go

K6 extension that adds support for browser automation and end-to-end web testing using playwright-go

k6 extension that adds support for browser automation and end-to-end web testing using playwright-go

Dec 21, 2022

Small demo of using physac 2d physics engine in golang

Physac-go 2D physics engine in golang For now this is just a small demo. Maybe later I'll convert it into a proper module. References Original Physac

Jul 26, 2022

A sub module of EdgeGallery MECM which responsible for the app lifecycle management

mecm-applcm Description Application life cycle manager is part of MEP manager whose responsibility is to handle the host level life cycle management i

Jan 10, 2022

A sub module of EdgeGallery MECM which responsible for the app rule management

mecm-apprulemgr 介绍 Application rule manager 软件架构 软件架构说明 安装教程 xxxx xxxx xxxx 使用说明 xxxx xxxx xxxx 参与贡献 Fork 本仓库 新建 Feat_xxx 分支 提交代码 新建 Pull Request 特技 使

Jan 24, 2022

Terraform utility provider for constructing bash scripts that use data from a Terraform module

Terraform Bash Provider This is a Terraform utility provider which aims to robustly generate Bash scripts which refer to data that originated in Terra

Sep 6, 2022

A lightweight Vault client module written in Go, with no dependencies, that is intuitive and user-friendly

libvault A lightweight Hashicorp Vault client written in Go, with no dependencies. It aims to provide an intuitive, simple API that is easy to use. Ju

Sep 18, 2022

A Terraform module that creates AWS alerts billing for your resources.

terraform-aws-billing-alarms terraform-aws-billing-alarms for project Replace name project to New Project agr 'terraform-aws-billing-alarms' 'new-pr

Oct 20, 2021

Go module for interacting with public ECR repositories

go-publicecr go-publicecr is a module for listing ECR image tags on a public ECR repository. Why go-publicecr The official Go SDK does not support int

Nov 24, 2021

Terraform module to provisison Kubernetes Clusters on Hetzner cloud (Based on KubeOne)

Terraform module template Terraform module which creates describe your intent resources on AWS. Usage Use this template to scaffold a new terraform mo

Nov 26, 2021
Comments
  • Is it compatible with 4.6?

    Is it compatible with 4.6?

    Is it compatible with 4.6? It is giving incompatibility with the opencv version. I can't generate the dll Would you like to update to a more current version equal to 4.6

Nvidia GPU exporter for prometheus using nvidia-smi binary
Nvidia GPU exporter for prometheus using nvidia-smi binary

nvidia_gpu_exporter Nvidia GPU exporter for prometheus, using nvidia-smi binary to gather metrics. Introduction There are many Nvidia GPU exporters ou

Jan 5, 2023
A kubernetes plugin which enables dynamically add or remove GPU resources for a running Pod
A kubernetes plugin which enables dynamically add or remove GPU resources for a running Pod

GPU Mounter GPU Mounter is a kubernetes plugin which enables add or remove GPU resources for running Pods. This Introduction(In Chinese) is recommende

Jan 5, 2023
NVIDIA GPU metrics exporter for Prometheus leveraging DCGM

DCGM-Exporter This repository contains the DCGM-Exporter project. It exposes GPU metrics exporter for Prometheus leveraging NVIDIA DCGM. Documentation

Dec 27, 2022
OpenAIOS vGPU scheduler for Kubernetes is originated from the OpenAIOS project to virtualize GPU device memory.
OpenAIOS vGPU scheduler for Kubernetes is originated from the OpenAIOS project to virtualize GPU device memory.

OpenAIOS vGPU scheduler for Kubernetes English version|中文版 Introduction 4paradigm k8s vGPU scheduler is an "all in one" chart to manage your GPU in k8

Jan 3, 2023
Wirewold cellular automata simulator, running entirely on GPU.

Wireworld-gpu Wireworld implements the data and rules for the Wireworld cellular automata. This particular version is an experiment whereby the simula

Dec 31, 2022
gpupod is a tool to list and watch GPU pod in the kubernetes cluster.

gpupod gpupod is simple tool to list and watch GPU pod in kubernetes cluster. usage Usage: gpupod [flags] Flags: -t, --createdTime with pod c

Dec 8, 2021
Planet Scale Robotics - Offload computation-heavy robotic operations to GPU powered world's first cloud-native robotics platform.

robolaunch ?? Planet Scale Robotics - Offload computation-heavy robotic operations to GPU powered world's first cloud-native robotics platform. robola

Jan 1, 2023
AutoGpuAffinity - Auto Gpu Affinity with golang
AutoGpuAffinity - Auto Gpu Affinity with golang

AutoGpuAffinity The idea and concept is from AMIT (repository) Formulas for calc

Dec 15, 2022
kubernetes Display Resource (CPU/Memory/Gpu/PodCount) Usage and Request and Limit.
kubernetes Display Resource (CPU/Memory/Gpu/PodCount) Usage and Request and Limit.

kubectl resource-view A plugin to access Kubernetes resource requests, limits, and usage. Display Resource (CPU/Memory/Gpu/PodCount) Usage and Request

Apr 22, 2022
Defalyzer: A cross-platform software that focuses on defacement analyzing and mirror tracking
Defalyzer: A cross-platform software that focuses on defacement analyzing and mirror tracking

Project Defalyzer is a cross-platform software that focuses on defacement analyz

Jul 26, 2022