PureBasic Interface to OpenCV

Developed or developing a new product in PureBasic? Tell the world about it.
mcederavic
New User
New User
Posts: 4
Joined: Fri Jan 12, 2018 8:26 am

Re: PureBasic Interface to OpenCV

Post by mcederavic »

Hello JHPJHP,
First of all, thanks a lot for your work, i'm using it to take photo with an integrated webcam of a HP Tablet but i have a problem to change the resolution.
The webcam is capable of streming in 1080p and can take 5mp photo (rear cam OV5670, wich works great with windows camera app) but whenever I try a resolution above 1280x960 it falls back to it.
The example "pb_webcam_resolution.pb" actually shows that the max resolution is 1280x960 but the windows camera app can take photo above that.
I tried to set FOURCC with MJPG or YUY2 but it didn't help.
Have you an idea?

Thanks!
AAT
Enthusiast
Enthusiast
Posts: 256
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

Hi JHPJHP!
Sorry, I will try to answer the question posed to you.

Hi, mcederavic.
Your OV5670 have 2592*1944 image size (max).

So, in the exmple pb_webcam_resolution.pb try to change

Code: Select all

Procedure ResolutionList(MaxWidth = 1280, nInterval = 100)
to

Code: Select all

Procedure ResolutionList(MaxWidth = 2592, nInterval = 162)
mcederavic
New User
New User
Posts: 4
Joined: Fri Jan 12, 2018 8:26 am

Re: PureBasic Interface to OpenCV

Post by mcederavic »

Hello AAT,
Thanks for your reply, unfortunately it did not change. Available resolutions are still 640x360 or 1280x960
AAT
Enthusiast
Enthusiast
Posts: 256
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

mcederavic, specify the exact name of your HP Tablet, please.

I think, your tablet have two cams and you trying to set high resolution to cam with low resolution, forexample, to front cam.
Add one more change to example: change the cam number

Code: Select all

  *capture = cvCreateCameraCapture(#CV_CAP_ANY)
to

Code: Select all

  *capture = cvCreateCameraCapture(1)

or other number, not 0
mcederavic
New User
New User
Posts: 4
Joined: Fri Jan 12, 2018 8:26 am

Re: PureBasic Interface to OpenCV

Post by mcederavic »

Yes I took the rear cam (and I see the rendered preview in the window)
The tablet is a HP Notebook x2 - 10-p028nf

I tried to capture in 1920x1080 with VLC but it fail to initialize too... I'm wondering if it is a hardware / driver lock
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi mcederavic,

Try the following: ... OpenCV access webcam maximum resolution
- set the resolution to something larger (e.g. 3000x3000)
stackoverflow wrote:I got it to work, so this post is for others experiencing the same problem:

I am running on the Logitech C270 as well. For some reason it would only show 640x480 even though the webcam supports 1280x720. Same issue persists with the built-in webcam in my laptop.

If I set it to 800x600 in the code it shows 640x480. However, if I set it to 1024x768 it becomes 800x600. And if I set it to something silly like 2000x2000 it becomes 1280x720.

This is in C++ on OpenCV 3.0, but perhaps it applies to Python as well.
If you are live streaming from your tablet, have you looked at the FFMPEG / RTSP example.

You may also want to try a different version of the download: PureBasic Interface to OpenCV 2.4.13.3 vs PureBasic Interface to OpenCV 3.3.
- OpenCV 3.3 was built using the World option (single DLL / LIB)
AAT
Enthusiast
Enthusiast
Posts: 256
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

mcederavic, read this topic http://www.purebasic.fr/english/viewtop ... 12&t=69059
Download opencv libs with reordered mediaSubtypes from http://rgho.st/84FfzcJrp
Replace the opencv libraries from the JHPJHP package with downloaded ones and try your code again.
mcederavic
New User
New User
Posts: 4
Joined: Fri Jan 12, 2018 8:26 am

Re: PureBasic Interface to OpenCV

Post by mcederavic »

Hello AAT / JHPJHP

I tried both OpenCV 2.4.13 and 3.3 and got same results. I also tried all known resolution and iterating up to 8192x8192 one by one but the max alowed is always 1288x960 event with the reordered lib.
I will try with an external usb cam.
Thanks for your help!
Morty
User
User
Posts: 35
Joined: Mon Mar 19, 2007 8:30 am
Location: Germany
Contact:

Re: PureBasic Interface to OpenCV

Post by Morty »

Hi JHPJHP,

thanks for these great codes and for your work.

I have a problem with tesseract and german traineddata. I downloaded this file:
https://github.com/tesseract-ocr/tessda ... raineddata

After that I copied the file into the folder "binaries\tesseract\tessdata" and changed it in the sourcecode

Code: Select all

hAPI = TesseractInit(#PSM_AUTO, #OEM_TESSERACT_ONLY, #PB_Compiler_FilePath + "binaries/tesseract/tessdata", "deu", #Null$)
If I run the code I get an memory-error (Read-Error ad Address 0) in pb_tesseract.pbi - Line 104

Code: Select all

 If TessBaseAPIInit1(hAPI, dictionarypath, language, OEM, @CFG, 1) : TessBaseAPIEnd(hAPI) : Else : ProcedureReturn hAPI : EndIf
It seems, that there is a conflict with the traineddata file. Am I missing something?
Do you have a suggestion?

Thanks,
Morty
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi Morty

The problem is with the traineddata version; try the following link:
- Data Files for Version 3.02

Another option is to replace the binaries with the current version, but then you may also have to update the code.
Morty
User
User
Posts: 35
Joined: Mon Mar 19, 2007 8:30 am
Location: Germany
Contact:

Re: PureBasic Interface to OpenCV

Post by Morty »

Good morning JHPJHP,

I thank you a thousand times :D With these files it works. I only wonder a bit, because the german files are much smaller than the origin english wone.
Where is the donation button? 8)

- Morty
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi Morty,

I am glad I was able to help. It is nice to know that the interface has found an audience.
Morty wrote:... I only wonder a bit, because the german files are much smaller than the origin english wone.
Sorry, I cannot find any documentation on why the file sizes are so different, but it is standard across versions.
Morty wrote:Where is the donation button?
Not necessary, but if you still want to buy me a coffee... My PureBasic Stuff - Unfinished (website) located in the footer of my posts, has a Donate button.
Morty
User
User
Posts: 35
Joined: Mon Mar 19, 2007 8:30 am
Location: Germany
Contact:

Re: PureBasic Interface to OpenCV

Post by Morty »

Good morning,

I've send you a few dollars for coffee ;-)

Thank you again and have a nice day.

- Morty
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi Morty,
Good morning,

I've send you a few dollars for coffee ;-)

Thank you again and have a nice day.

- Morty
I just noticed that you had not read my PM, and I wanted you to know that I am grateful for the coffee.

Cheers :!:
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated: ( OpenCV 2.4.13.3 to OpenCV 2.4.13.6 )
- Demo Download: PureBasic Interface to OpenCV :: 32 bit
- Main Download: PureBasic Interface to OpenCV :: 32 bit
- Demo Download: PureBasic Interface to OpenCV :: 64 bit
- Main Download: PureBasic Interface to OpenCV :: 64 bit

Other Changes:
- replaced reference files
- removed 4 examples (might be temporary)
- removed MS Runtime DLLs (users with an older version of Windows may need to provide their own)

NB*: When time permits, I will be updating the rest of the packages.
Locked