Skip to content

Create install-webcam.sh#1

Open
SterlingButters wants to merge 1 commit into
grandchild:masterfrom
SterlingButters:patch-2
Open

Create install-webcam.sh#1
SterlingButters wants to merge 1 commit into
grandchild:masterfrom
SterlingButters:patch-2

Conversation

@SterlingButters

Copy link
Copy Markdown

Automates everything to install kinect as a webcam

Automates everything to install kinect as a webcam

@grandchild grandchild left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

sorry for taking so long to get to this, and thanks for the script!
But I'm not sure about just dumping a script in the repo.

I'd find it better if these steps would be generalized to other distros (no apt) and broken up with explanatory sections in between. That wouldn't be a .sh file but rather an INSTALL.md or similar. If you don't feel like doing a proper writeup that's okay -- I might do that at some point.

Comment thread install-webcam.sh
@@ -0,0 +1,44 @@
apt-get install ffmpeg

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a better fit for the README. Not everyone runs Debian or Ubuntu.

Comment thread install-webcam.sh
Comment on lines +8 to +9
cp gspca_kinect_main.ko /lib/modules/`uname -r`/kernel/drivers/kinect/gspca_kinect_main.ko
cp gspca_kinect2.ko /lib/modules/`uname -r`/kernel/drivers/kinect/gspca_kinect2.ko

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't these have to be run as root? Hint: The answer is not to run the whole script as root.

Comment thread install-webcam.sh
fi
done

echo "options video_nr=10 card_label='Kinect v2'" > /etc/modprobe.d/v4l2loopback.conf

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Root needed again.

Comment thread install-webcam.sh
Comment on lines +33 to +41
echo "[Unit]
Description=V4L2 Loopback Service for Kinect Webcam

[Service]
Type=simple
ExecStart=ffmpeg -i /dev/video0 -vsync drop -filter:v fps=30,scale=1280:-1,hflip -pix_fmt yuyv422 -color_trc bt709 -color_primaries bt709 -color_range tv -f v4l2 /dev/video10

[Install]
WantedBy=multi-user.target" > /lib/systemd/system/v4l2-kinect.service

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this would be better as a separate file in this repository. so it can be cped.

Comment thread install-webcam.sh
Comment on lines +43 to +44
echo "Enabling v4l2-loopback.service at boot"
systemctl enable v4l2-loopback

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be left to the user, not done in an install script.

@SterlingButters

Copy link
Copy Markdown
Author

@grandchild I agree with most of your comments. I figured if I came up with the script myself I might as well share it i.e. my goal wasn't to make it work in general - it was just something I had already done. You are correct that the script is needed to be run as root - I know why this is disadvantageous but I just needed a "quick-fix". I am actually pretty unfamiliar with how to draft/use an INSTALL.md so I won't be of much help there. I also think at the very least the install script should ask the user if they would like the service enabled at boot (must easier to just confirm "y" than to type all that extra junk). I like the idea of the separate .service file - it also makes more sense in this application when hosted in a repo (not sure how you could do this with a single install script/file like I did)

@grandchild

Copy link
Copy Markdown
Owner

Hey, that's cool :)

I will just make an install.md from your script myself -- I really don't mind. I just wanted to check what your involvement in this is. If this is just a quick script, then you'll not mind. But people are sometimes more... possessive(?) about their code and want to do things themselves, that's why I asked :)

Thanks for the script again (and the systemd service) it'll serve as a nice starting point.

@SterlingButters

Copy link
Copy Markdown
Author

Awesome! I'll be excited to see it implemented then! I don't care about ownership of this script particularly - credit is always nice but at the end of the day if it results in a better product for me to use then I am happy. Thanks for being a responsive dev - I always like to see that.

Note I had some problems with this script on one of the Ubuntu kernels and then when the kernel updated it worked again so idk what that was all about.

@JakeSays

Copy link
Copy Markdown

I would much rather have this as a usable script than as documentation. Scripts are almost always more likely to be updated than the docs.

@vncscoelho

vncscoelho commented May 24, 2021

Copy link
Copy Markdown

The script ran OK, except when tried to start the service. Ubuntu 21.04. Any idea?

root@vinicius-work:/home/vinicius/gspca-kinect2# ./install-webcam.sh 
Lendo listas de pacotes... Pronto
Construindo árvore de dependências... Pronto
Lendo informação de estado... Pronto        
ffmpeg já é a versão mais recente (7:4.3.2-0+deb11u1ubuntu1).
0 pacotes atualizados, 0 pacotes novos instalados, 0 a serem removidos e 55 não atualizados.
Cloning GSPCA Repo...
fatal: destination path 'gspca-kinect2' already exists and is not an empty directory.
Building & Installing Modules (copying into /lib/modules/5.11.0-17-generic/kernel/drivers/kinect)
make: Entrando no diretório '/usr/src/linux-headers-5.11.0-17-generic'
  CLEAN   /home/vinicius/gspca-kinect2/Module.symvers
  CC [M]  /home/vinicius/gspca-kinect2/kinect2.o
  LD [M]  /home/vinicius/gspca-kinect2/gspca_kinect2.o
  CC [M]  /home/vinicius/gspca-kinect2/gspca.o
  LD [M]  /home/vinicius/gspca-kinect2/gspca_main.o
  MODPOST /home/vinicius/gspca-kinect2/Module.symvers
  CC [M]  /home/vinicius/gspca-kinect2/gspca_kinect2.mod.o
  LD [M]  /home/vinicius/gspca-kinect2/gspca_kinect2.ko
  BTF [M] /home/vinicius/gspca-kinect2/gspca_kinect2.ko
Skipping BTF generation for /home/vinicius/gspca-kinect2/gspca_kinect2.ko due to unavailability of vmlinux
  CC [M]  /home/vinicius/gspca-kinect2/gspca_main.mod.o
  LD [M]  /home/vinicius/gspca-kinect2/gspca_main.ko
  BTF [M] /home/vinicius/gspca-kinect2/gspca_main.ko
Skipping BTF generation for /home/vinicius/gspca-kinect2/gspca_main.ko due to unavailability of vmlinux
make: Saindo do diretório '/usr/src/linux-headers-5.11.0-17-generic'
Cloning V4L2Loopback Repo...
fatal: destination path 'v4l2loopback' already exists and is not an empty directory.
Building and Installing Modules
make: *** Nenhum alvo indicado e nenhum arquivo make encontrado.  Pare.
Resolving Module Dependencies
Enabling GSPCA & V4L2Loopback Modules at boot
videodev found - skipping...
gspca_kinect_main found - skipping...
gspca_kinect2 found - skipping...
v4l2loopback found - skipping...
Creating ffmpeg service v4l2-loopback.service
Enabling v4l2-loopback.service at boot
Failed to enable unit: Unit file v4l2-loopback.service does not exist.

@SterlingButters

SterlingButters commented May 25, 2021

Copy link
Copy Markdown
Author

What is output of systemctl list-unit-files | grep v4l2

@khrsantiago

Copy link
Copy Markdown

Can I use this scrip to Kinect v1?

@Marietto2008

Copy link
Copy Markdown

I tried to compile and run the driver "gspca-kinect2" because I want that my kinect 2 is detected as webcam inside obs and skype for linux,but as u can see below,it does not work :

marietto@marietto-BHYVE:~/Scrivania/gspca-kinect2$ uname -a

Linux marietto-BHYVE 5.13.0-27-generic #29-Ubuntu SMP Wed Jan 12 17:36:47 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

marietto@marietto-BHYVE:~/Scrivania/gspca-kinect2$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.10
Release: 21.10
Codename: impish

marietto@marietto-BHYVE:~/Scrivania$ git clone https://github.com/grandchild/gspca-kinect2.git

Clone in 'gspca-kinect2' in corso...
remote: Enumerating objects: 95, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 95 (delta 6), reused 8 (delta 3), pack-reused 81
Ricezione degli oggetti: 100% (95/95), 69.96 KiB | 884.00 KiB/s, fatto.
Risoluzione dei delta: 100% (52/52), fatto.

marietto@marietto-BHYVE:~/Scrivania$ cd gspca-kinect2

marietto@marietto-BHYVE:~/Scrivania/gspca-kinect2$ ls

gspca.c gspca.h kinect2.c kinect2.h LICENSE Makefile README.md

marietto@marietto-BHYVE:~/Scrivania/gspca-kinect2$ make -C /lib/modules/uname -r/build M=pwd SRCROOT=pwd clean modules
make: ingresso nella directory «/usr/src/linux-headers-5.13.0-27-generic»
CC [M] /home/marietto/Scrivania/gspca-kinect2/kinect2.o
LD [M] /home/marietto/Scrivania/gspca-kinect2/gspca_kinect2.o
CC [M] /home/marietto/Scrivania/gspca-kinect2/gspca.o
LD [M] /home/marietto/Scrivania/gspca-kinect2/gspca_main.o
MODPOST /home/marietto/Scrivania/gspca-kinect2/Module.symvers
CC [M] /home/marietto/Scrivania/gspca-kinect2/gspca_kinect2.mod.o
LD [M] /home/marietto/Scrivania/gspca-kinect2/gspca_kinect2.ko
BTF [M] /home/marietto/Scrivania/gspca-kinect2/gspca_kinect2.ko
Skipping BTF generation for /home/marietto/Scrivania/gspca-kinect2/gspca_kinect2.ko due to unavailability of vmlinux
CC [M] /home/marietto/Scrivania/gspca-kinect2/gspca_main.mod.o
LD [M] /home/marietto/Scrivania/gspca-kinect2/gspca_main.ko
BTF [M] /home/marietto/Scrivania/gspca-kinect2/gspca_main.ko
Skipping BTF generation for /home/marietto/Scrivania/gspca-kinect2/gspca_main.ko due to unavailability of vmlinux
make: uscita dalla directory «/usr/src/linux-headers-5.13.0-27-generic»

marietto@marietto-BHYVE:~/Scrivania/gspca-kinect2$ sudo /sbin/modprobe videodev

marietto@marietto-BHYVE:~/Scrivania/gspca-kinect2$ sudo /sbin/insmod ./gspca_main.ko
insmod: ERROR: could not insert module ./gspca_main.ko: Unknown symbol in module

marietto@marietto-BHYVE:~/Scrivania/gspca-kinect2$ sudo /sbin/insmod ./gspca_main.ko
insmod: ERROR: could not insert module ./gspca_main.ko: Unknown symbol in module

marietto@marietto-BHYVE:~/Scrivania/gspca-kinect2$ sudo /sbin/insmod ./gspca_kinect2.ko
insmod: ERROR: could not insert module ./gspca_kinect2.ko: Unknown symbol in module

@Jenni32222

Copy link
Copy Markdown

What is output of systemctl list-unit-files | grep v4l2

Wondering if anyone is still working on this.

Anyway, I had the same error as @vncscoelho and the output of your command was
v4l2-kinect.service disabled enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants