OpenCV to capture an image with a webcam?
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
OpenCV to capture an image with a webcam?
Is it possible to use OpenCV to capture webcam images for use in a FreeBASIC program?
At the moment I am using escapi.bi and escapi.dll but they are window's dependent and I would like to do the same with the Linux os.
At the moment I am using escapi.bi and escapi.dll but they are window's dependent and I would like to do the same with the Linux os.
Re: OpenCV to capture an image with a webcam?
Maybe possible with libVLC? viewtopic.php?f=14&t=24028
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: OpenCV to capture an image with a webcam?
Downloaded the folder from SourceForge into my FreeBASIC folder.
Ran Joshy's example but it failed.
Looks like I have some google exploring to do or just forget about using FreeBasic with Linux and just using Processing or Python which is well supported in this area.
Command executed:
"C:\FreeBasic\fbc.exe" "C:\FreeBasic\simplest_libvlc_example\vlcTest.bas"
Compiler output:
C:\FreeBasic\bin\win32\ld.exe: cannot find -lvlc
Results:
Compilation failed
System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)
Ran Joshy's example but it failed.
Looks like I have some google exploring to do or just forget about using FreeBasic with Linux and just using Processing or Python which is well supported in this area.
Command executed:
"C:\FreeBasic\fbc.exe" "C:\FreeBasic\simplest_libvlc_example\vlcTest.bas"
Compiler output:
C:\FreeBasic\bin\win32\ld.exe: cannot find -lvlc
Results:
Compilation failed
System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)
Re: OpenCV to capture an image with a webcam?
What does locate libvlc.so say?
Here:
/usr/lib/x86_64-linux-gnu/libvlc.so
/usr/lib/x86_64-linux-gnu/libvlc.so.5
/usr/lib/x86_64-linux-gnu/libvlc.so.5.6.0
And if I check with ls -l /usr/lib/x86_64-linux-gnu/libvlc.*
lrwxrwxrwx 1 root root 15 Sep 11 13:39 /usr/lib/x86_64-linux-gnu/libvlc.so -> libvlc.so.5.6.0
lrwxrwxrwx 1 root root 15 Sep 11 13:39 /usr/lib/x86_64-linux-gnu/libvlc.so.5 -> libvlc.so.5.6.0
-rw-r--r-- 1 root root 153512 Sep 11 13:39 /usr/lib/x86_64-linux-gnu/libvlc.so.5.6.0
Which tells me the version.
On Ubuntu, I can say sudo apt-get install libvlc
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libvlc
I check with the "Synaptic Package Manager" (first thing to install on a new Ubuntu install), I see that it is named libvlc5
So, sudo apt-get install libvlc5
Reading package lists... Done
Building dependency tree
Reading state information... Done
libvlc5 is already the newest version (3.0.8-0ubuntu18.04.1)
...
I have tried something (play a movie clip, not with a webcam) with libvlc some time ago, it worked. Probably only with 64-bit fbc, as I don't have libvlc5:i386 installed here.
Here:
/usr/lib/x86_64-linux-gnu/libvlc.so
/usr/lib/x86_64-linux-gnu/libvlc.so.5
/usr/lib/x86_64-linux-gnu/libvlc.so.5.6.0
And if I check with ls -l /usr/lib/x86_64-linux-gnu/libvlc.*
lrwxrwxrwx 1 root root 15 Sep 11 13:39 /usr/lib/x86_64-linux-gnu/libvlc.so -> libvlc.so.5.6.0
lrwxrwxrwx 1 root root 15 Sep 11 13:39 /usr/lib/x86_64-linux-gnu/libvlc.so.5 -> libvlc.so.5.6.0
-rw-r--r-- 1 root root 153512 Sep 11 13:39 /usr/lib/x86_64-linux-gnu/libvlc.so.5.6.0
Which tells me the version.
On Ubuntu, I can say sudo apt-get install libvlc
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libvlc
I check with the "Synaptic Package Manager" (first thing to install on a new Ubuntu install), I see that it is named libvlc5
So, sudo apt-get install libvlc5
Reading package lists... Done
Building dependency tree
Reading state information... Done
libvlc5 is already the newest version (3.0.8-0ubuntu18.04.1)
...
I have tried something (play a movie clip, not with a webcam) with libvlc some time ago, it worked. Probably only with 64-bit fbc, as I don't have libvlc5:i386 installed here.
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: OpenCV to capture an image with a webcam?
Sorry brain glitch!! I had been trying to compile it on windows10.
It has been some time since I last ran a FreeBASIC program on the RPi and my knowledge and experience with Linux has been very limited. The example code and vlc download stuff was on a ram stick. The Linux directory system is a little different to Windows and it took time to find the ram stick in the directory. Anyway I eventually ran the code example with this result:
fbc -w all "vlcTest.bas" (in directory: /media/pi/C6DB-5276/simplest_libvlc_example)
vlcTest.bas(4) error 23: File not found, "vlc/vlc.bi" in '#include once "vlc/vlc.bi"'
Compilation failed.
I was unable to locate the vlc.bi
Looks like I am going to have to spend time relearning and extending my knowledge of Linux on the RPi. As I get older I find remembering new things and recalling them later is becoming more difficult!
It has been some time since I last ran a FreeBASIC program on the RPi and my knowledge and experience with Linux has been very limited. The example code and vlc download stuff was on a ram stick. The Linux directory system is a little different to Windows and it took time to find the ram stick in the directory. Anyway I eventually ran the code example with this result:
fbc -w all "vlcTest.bas" (in directory: /media/pi/C6DB-5276/simplest_libvlc_example)
vlcTest.bas(4) error 23: File not found, "vlc/vlc.bi" in '#include once "vlc/vlc.bi"'
Compilation failed.
I was unable to locate the vlc.bi
Looks like I am going to have to spend time relearning and extending my knowledge of Linux on the RPi. As I get older I find remembering new things and recalling them later is becoming more difficult!
Re: OpenCV to capture an image with a webcam?
I cannot remember the details when I tried libvlc, but vlc.bi seems to bee in the freebasic installation since at least version 0.90.0:
Code: Select all
locate vlc.bi
/home/badidea/Downloads/FB/FreeBASIC-0.90.0-source/inc/vlc/libvlc.bi
/home/badidea/Downloads/FB/FreeBASIC-0.90.0-source/inc/vlc/vlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.05.0-linux-x86/include/freebasic/vlc/libvlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.05.0-linux-x86/include/freebasic/vlc/vlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.05.0-linux-x86_64/include/freebasic/vlc/libvlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.05.0-linux-x86_64/include/freebasic/vlc/vlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.06.0-linux-x86_64/include/freebasic/vlc/libvlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.06.0-linux-x86_64/include/freebasic/vlc/vlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.07.0-linux-x86/include/freebasic/vlc/libvlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.07.0-linux-x86/include/freebasic/vlc/vlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.07.0-linux-x86_64/include/freebasic/vlc/libvlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.07.0-linux-x86_64/include/freebasic/vlc/vlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.07.0-source/inc/vlc/libvlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.07.0-source/inc/vlc/vlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.07.1-linux-x86/include/freebasic/vlc/libvlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.07.1-linux-x86/include/freebasic/vlc/vlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.07.1-linux-x86_64/include/freebasic/vlc/libvlc.bi
/home/badidea/Downloads/FB/FreeBASIC-1.07.1-linux-x86_64/include/freebasic/vlc/vlc.bi
/usr/local/include/freebasic/vlc/libvlc.bi
/usr/local/include/freebasic/vlc/vlc.bi
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: OpenCV to capture an image with a webcam?
Where did you type locate vlc.bi ?
All I can find in my FreeBasic folder is fbc_linux_armv7a_hf_debian
The bin, doc, inlcude and lib folders seem empty.
The vlc.bi is in the Windows version of FreeBasic.
All I can find in my FreeBasic folder is fbc_linux_armv7a_hf_debian
The bin, doc, inlcude and lib folders seem empty.
The vlc.bi is in the Windows version of FreeBasic.
Re: OpenCV to capture an image with a webcam?
At the terminal. But I don't know anything about RPi's.BasicCoder2 wrote:Where did you type locate vlc.bi ?
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: OpenCV to capture an image with a webcam?
Thank you for your responses.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: OpenCV to capture an image with a webcam?
download freebasic_additional_headers.zip from here http://users.freebasic-portal.de/stw/builds/
unzip it and copy the folder inc over your FreeBASIC include folder
or copy only the inc/vlc folder to you FreeBASIC include folder
Joshy
unzip it and copy the folder inc over your FreeBASIC include folder
or copy only the inc/vlc folder to you FreeBASIC include folder
Joshy
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: OpenCV to capture an image with a webcam?
Thanks Joshy I will give it a try later.
Re: OpenCV to capture an image with a webcam?
I have used opencv from fb but might be too much work:
Write opencv code in C++ but Use export Dll functions to expose to fb. Fb calls the dll functions and it loads bitmap memory, you then blit to your form.
My actual implementation was Rapidq forms > fb c wrapper > DLL with c++ code. Sounds complicated but worked great.
Direct from fb will be nearly impossible because of c++ vector types and c++ templates. The good news is that working opencv code is everywhere
Sorry the code is not for sharing. :(
Write opencv code in C++ but Use export Dll functions to expose to fb. Fb calls the dll functions and it loads bitmap memory, you then blit to your form.
My actual implementation was Rapidq forms > fb c wrapper > DLL with c++ code. Sounds complicated but worked great.
Direct from fb will be nearly impossible because of c++ vector types and c++ templates. The good news is that working opencv code is everywhere
Sorry the code is not for sharing. :(
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: OpenCV to capture an image with a webcam?
Do you use escapi3 the 64-bit version on Windows 10 ?BasicCoder2 wrote:... At the moment I am using escapi.bi and escapi.dll ...
(I can't use my cameras on 64-bit windows)
https://sol.gfxile.net/escapi/index.html
Joshy
Re: OpenCV to capture an image with a webcam?
This is not native FB code but is relevant if you want to interface FB to OpenCV. FB and RQ are very similar except for GUI
I have uploaded my QOpenCV DLL and interface to the public. It uses the OpenCV 2.2 library (32-bit). This is a powerful image processing library that allows video playback and webcam capture. I uploaded the old library to be compatible with windows XP (32-bit), so that means modern webcams may not be supported!. It comes with pre-compiled binaries and C++ source code.in case you want to compile your own with the updated OpenCV library
You will find it here:
http://rapidq.phatcode.net/examples/vid ... istrib.zip
and the readme here:
http://rapidq.phatcode.net/examples/video/ReadMe.txt
Enjoy
JK
I have uploaded my QOpenCV DLL and interface to the public. It uses the OpenCV 2.2 library (32-bit). This is a powerful image processing library that allows video playback and webcam capture. I uploaded the old library to be compatible with windows XP (32-bit), so that means modern webcams may not be supported!. It comes with pre-compiled binaries and C++ source code.in case you want to compile your own with the updated OpenCV library
You will find it here:
http://rapidq.phatcode.net/examples/vid ... istrib.zip
and the readme here:
http://rapidq.phatcode.net/examples/video/ReadMe.txt
Enjoy
JK