original fw + ftrobopy+ OpenCV ?

Community-Firmware (cfw), Selbstbaucontroller (TX-Pi, ftduino, usw.), usw.
Forumsregeln
Bitte beachte die Forumsregeln!
Antworten
hvn
Beiträge: 256
Registriert: 20 Feb 2011, 11:15

original fw + ftrobopy+ OpenCV ?

Beitrag von hvn » 18 Okt 2017, 15:12

@Torsten as discussed in http://forum.ftcommunity.de/viewtopic.php?f=33&t=4470, is it possible to add OpenCV to ftrobopy somehow so it can be used on the original firmware?

Thank you.

hvn

Torsten
Beiträge: 308
Registriert: 29 Jun 2015, 23:08
Wohnort: Gernsheim (Rhein-Main-Region)

Re: original fw + ftrobopy+ OpenCV ?

Beitrag von Torsten » 18 Okt 2017, 20:50

Hi hvn,
hvn hat geschrieben:@Torsten as discussed in http://forum.ftcommunity.de/viewtopic.php?f=33&t=4470, is it possible to add OpenCV to ftrobopy somehow so it can be used on the original firmware?

Thank you.

hvn
I think that it is possible but it would need quite some work. OpenCV is a big package and depends on many other modules that all would have to be ported. Since OpenCV is nicely supported under the cfw this is the way to go. I don't see myself porting OpenCV to the original firmware soon (or ever).
If you need camera access with the original firmware you could use the v4l-Libraries (see my ftDigiCam-Project).

Best,
Torsten

hvn
Beiträge: 256
Registriert: 20 Feb 2011, 11:15

Re: original fw + ftrobopy+ OpenCV ?

Beitrag von hvn » 19 Okt 2017, 08:59

Hi Torsten,

Thank you for the answer. Didn't know about that project and will give it a try.

Regards,

hvn

hvn
Beiträge: 256
Registriert: 20 Feb 2011, 11:15

Re: original fw + ftrobopy+ OpenCV ?

Beitrag von hvn » 23 Okt 2017, 21:35

I installed ftrobopytools and get a pixel error using .initCam(fps, width, height, 0, 0) while partly following your github example, actually on both firmwares. Any idea why?

Torsten
Beiträge: 308
Registriert: 29 Jun 2015, 23:08
Wohnort: Gernsheim (Rhein-Main-Region)

Re: original fw + ftrobopy+ OpenCV ?

Beitrag von Torsten » 23 Okt 2017, 22:07

hvn hat geschrieben:I installed ftrobopytools and get a pixel error using .initCam(fps, width, height, 0, 0) while partly following your github example, actually on both firmwares. Any idea why?
What error do you exactly get ? and how does your python script look like ?

hvn
Beiträge: 256
Registriert: 20 Feb 2011, 11:15

Re: original fw + ftrobopy+ OpenCV ?

Beitrag von hvn » 25 Okt 2017, 13:36

The error I first got was: "ftrobopytools.error: error set pixel format in cam_init
Now I get another error: "undefined symbol: Py_InitModule4".

What I used from you ftDigiCam.py is the initialization:

import ftrobopytools

fps = 15
width = 320
height = 240
videv = ftrobopytools.camInit(fps, width, height, 0, 0)

Torsten
Beiträge: 308
Registriert: 29 Jun 2015, 23:08
Wohnort: Gernsheim (Rhein-Main-Region)

Re: original fw + ftrobopy+ OpenCV ?

Beitrag von Torsten » 25 Okt 2017, 19:31

hvn hat geschrieben:The error I first got was: "ftrobopytools.error: error set pixel format in cam_init
Now I get another error: "undefined symbol: Py_InitModule4".

What I used from you ftDigiCam.py is the initialization:

import ftrobopytools

fps = 15
width = 320
height = 240
videv = ftrobopytools.camInit(fps, width, height, 0, 0)
The commands I can see here are correct but be aware that ftrobopytools can not be used together with the ftrobopy camera commands (startCameraOnline, stopCameraOnline and getCameraFrame). Make sure that ftrobopy.startCameraOnline is _not_ called, when using ftrobopytools.camInit(...)

hvn
Beiträge: 256
Registriert: 20 Feb 2011, 11:15

Re: original fw + ftrobopy+ OpenCV ?

Beitrag von hvn » 01 Nov 2017, 10:47

More info. First: the error I get now:

$ ./run_python Mirft2.py
Connected to TX2013 firmware version 4.2.4
Camera connected
Traceback (most recent call last):
File "Mirft2.py", line 41, in <module>
videv = ftrobopytools.camInit(fps, width, height, 0, 0)
ftrobopytools.error: error set pixel format in cam_init

Network error 'NoneType' object is not callable
Network error
Exception in thread Thread-3 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/opt/knobloch/lib/python2.7/threading.py", line 810, in __bootstrap_inner
File "/opt/knobloch/ftrobopy.py", line 1291, in run
<type 'exceptions.TypeError'>: 'NoneType' object is not callable

Then the code, taken from ftDigiCam.py at GitHub:

# cam init
fps = 15
width = 320
height = 240
videv = ftrobopytools.camInit(fps, width, height, 0, 0) # line 41
#take ftrobopytools image
jpg = ftrobopytools.getJPEGImage(videv)
ftrobopytools.camClose(videv, 0)
try:
with open(fname_prefix+'IDX','r') as f:
pict_number = int(f.read())
except:
pict_number = 0
with open(fname_prefix + '%04i' % pict_number +'.JPG', 'wb') as f:
f.write(jpg)
with open(fname_prefix+'IDX','w') as f:
f.write(str(pict_number + 1))
# rest of program

Initially I thought that txt.getCameraFrame() would harm, but that's in a separate function not being called yet at the time of this error.

Antworten