Python3 compatible OpenMV-IDE ...

General discussion about topics related to OpenMV.
User avatar
jiapei100
Posts: 33
Joined: Fri Oct 14, 2016 7:07 pm
Contact:

Python3 compatible OpenMV-IDE ...

Postby jiapei100 » Sun Jul 15, 2018 2:04 pm

Besides all print "XXX" to print ("XXX"), there are still a bunch of modifications need to be done...

Code: Select all

$ git diff scripts/common.py
diff --git a/scripts/common.py b/scripts/common.py
index 16785b83b5..b6fb00ddbd 100644
--- a/scripts/common.py
+++ b/scripts/common.py
@@ -88,7 +88,7 @@ def copytree(src, dst, symlinks=False, ignore=None):
 
 def get_qt_install_info(qmake_bin):
     output = subprocess.check_output([qmake_bin, '-query'])
-    lines = output.strip().split('\n')
+    lines = (bytes.decode( output.strip() )).split('\n')
     info = {}
     for line in lines:
         (var, sep, value) = line.partition(':')
@@ -103,13 +103,13 @@ def get_rpath(libfilepath, chrpath=None):
     except subprocess.CalledProcessError: # no RPATH or RUNPATH
         return []
     marker = 'RPATH='
-    index = output.find(marker)
+    index = bytes.decode(output).find(marker)
     if index < 0:
         marker = 'RUNPATH='
-        index = output.find(marker)
+        index = bytes.decode(output).find(marker)
     if index < 0:
         return []
-    return output[index + len(marker):].split(':')
+    return bytes.decode(output)[index + len(marker):].split(':')
 
 def fix_rpaths(path, qt_deploy_path, qt_install_info, chrpath=None):
     if chrpath is None:
@@ -153,7 +153,7 @@ def fix_rpaths(path, qt_deploy_path, qt_install_info, chrpath=None):
             lddOutput = subprocess.check_output(['ldd', filepath])
         #OPENMV-DIFF#
 
-        if lddOutput.find('libQt5') >= 0 or lddOutput.find('libicu') >= 0:
+        if bytes.decode(lddOutput).find('libQt5') >= 0 or bytes.decode(lddOutput).find('libicu') >= 0:
             # add Qt RPATH if necessary
             relative_path = os.path.relpath(qt_deploy_path, os.path.dirname(filepath))
             if relative_path == '.':
@@ -162,10 +162,10 @@ def fix_rpaths(path, qt_deploy_path, qt_install_info, chrpath=None):
                 relative_path = '/' + relative_path
             qt_rpath = '$ORIGIN' + relative_path
             if not any((path == qt_rpath) for path in rpath):
-                new_rpath.append(qt_rpath)
+                list(new_rpath).append(qt_rpath)
 
         # change RPATH
-        if len(new_rpath) > 0:
+        if len(list(new_rpath)) > 0:
             subprocess.check_call([chrpath, '-r', ':'.join(new_rpath), filepath])
         else: # no RPATH / RUNPATH left. delete.
             subprocess.check_call([chrpath, '-d', filepath])
@@ -173,8 +173,8 @@ def fix_rpaths(path, qt_deploy_path, qt_install_info, chrpath=None):
     def is_unix_executable(filepath):
         # Whether a file is really a binary executable and not a script and not a symlink (unix only)
         if os.path.exists(filepath) and os.access(filepath, os.X_OK) and not os.path.islink(filepath):
-            with open(filepath) as f:
-                return f.read(2) != "#!"
+            with open(filepath, 'r', encoding="ascii", errors="surrogateescape") as f:
+                return (f.read(2) != "#!")
 
     def is_unix_library(filepath):
         # Whether a file is really a library and not a symlink (unix only)
@@ -183,5 +183,5 @@ def fix_rpaths(path, qt_deploy_path, qt_install_info, chrpath=None):
     for dirpath, dirnames, filenames in os.walk(path):
         for filename in filenames:
             filepath = os.path.join(dirpath, filename)
-            if is_unix_executable(filepath) or is_unix_library(filepath):
+            if (is_unix_executable(filepath) or is_unix_library(filepath)):
                 fix_rpaths_helper(filepath)

[1]+  Stopped                 git diff scripts/common.py

Cheers
Pei
Welcome to Longer Vision
http://www.longervision.ca
User avatar
kwagyeman
Posts: 2286
Joined: Sun May 24, 2015 2:10 pm

Re: Python3 compatible OpenMV-IDE ...

Postby kwagyeman » Mon Jul 16, 2018 1:13 am

Um, PR to the github?
Nyamekye,
User avatar
jiapei100
Posts: 33
Joined: Fri Oct 14, 2016 7:07 pm
Contact:

Re: Python3 compatible OpenMV-IDE ...

Postby jiapei100 » Wed Jul 18, 2018 4:30 pm

I've already made openmv-ide be compatible with Python3 on my computer, but failed to pull request as shown in https://github.com/openmv/openmv-ide/issues/25 .
A lot of my modifications are under folder qt-creator https://github.com/openmv/qt-creator/tr ... b586538e6c .

I've got NO idea how to pull request to a submodule since qt-creator is NOT administrated by OpenMV.
Anyway, I listed all my modifications here FIRST, and then will figure out how to deal with submodule pull request.

1. General

Code: Select all

$ git log --author="jiapei100"
commit 0ed08e94a7f0f71a36e3edafc39e4a3529afbb09 (HEAD)
Author: jiapei100 <jp4work@gmail.com>
Date:   Sun Jul 15 11:01:47 2018 -0700

    print (), python3 compatible

commit bbac54519f88eca0d92f192ca28f81209255fbcd
Author: jiapei100 <jp4work@gmail.com>
Date:   Sat Jul 14 00:12:32 2018 -0700

    print (), with parenthesis

commit 756790674ce2a29aa8c7ed9acf3d44c20f35a70f
Author: jiapei100 <jp4work@gmail.com>
Date:   Sat Jul 14 00:00:55 2018 -0700

    #include <QButtonGroup>

commit be4ddaa955a6d020c3263eff0adfc73095a5e099
Author: jiapei100 <jp4work@gmail.com>
Date:   Sat Jul 14 00:00:37 2018 -0700

    #include <QAbstractItemView>
    
2. scripts/common.py

Code: Select all

$ git diff scripts/common.py
diff --git a/scripts/common.py b/scripts/common.py
index 16785b83b5..b6fb00ddbd 100644
--- a/scripts/common.py
+++ b/scripts/common.py
@@ -88,7 +88,7 @@ def copytree(src, dst, symlinks=False, ignore=None):
 
 def get_qt_install_info(qmake_bin):
     output = subprocess.check_output([qmake_bin, '-query'])
-    lines = output.strip().split('\n')
+    lines = (bytes.decode( output.strip() )).split('\n')
     info = {}
     for line in lines:
         (var, sep, value) = line.partition(':')
@@ -103,13 +103,13 @@ def get_rpath(libfilepath, chrpath=None):
     except subprocess.CalledProcessError: # no RPATH or RUNPATH
         return []
     marker = 'RPATH='
-    index = output.find(marker)
+    index = bytes.decode(output).find(marker)
     if index < 0:
         marker = 'RUNPATH='
-        index = output.find(marker)
+        index = bytes.decode(output).find(marker)
     if index < 0:
         return []
-    return output[index + len(marker):].split(':')
+    return bytes.decode(output)[index + len(marker):].split(':')
 
 def fix_rpaths(path, qt_deploy_path, qt_install_info, chrpath=None):
     if chrpath is None:
@@ -153,7 +153,7 @@ def fix_rpaths(path, qt_deploy_path, qt_install_info, chrpath=None):
             lddOutput = subprocess.check_output(['ldd', filepath])
         #OPENMV-DIFF#
 
-        if lddOutput.find('libQt5') >= 0 or lddOutput.find('libicu') >= 0:
+        if bytes.decode(lddOutput).find('libQt5') >= 0 or bytes.decode(lddOutput).find('libicu') >= 0:
             # add Qt RPATH if necessary
             relative_path = os.path.relpath(qt_deploy_path, os.path.dirname(filepath))
             if relative_path == '.':
@@ -162,10 +162,10 @@ def fix_rpaths(path, qt_deploy_path, qt_install_info, chrpath=None):
                 relative_path = '/' + relative_path
             qt_rpath = '$ORIGIN' + relative_path
             if not any((path == qt_rpath) for path in rpath):
-                new_rpath.append(qt_rpath)
+                list(new_rpath).append(qt_rpath)
 
         # change RPATH
-        if len(new_rpath) > 0:
+        if len(list(new_rpath)) > 0:
             subprocess.check_call([chrpath, '-r', ':'.join(new_rpath), filepath])
         else: # no RPATH / RUNPATH left. delete.
             subprocess.check_call([chrpath, '-d', filepath])
@@ -173,8 +173,8 @@ def fix_rpaths(path, qt_deploy_path, qt_install_info, chrpath=None):
     def is_unix_executable(filepath):
         # Whether a file is really a binary executable and not a script and not a symlink (unix only)
         if os.path.exists(filepath) and os.access(filepath, os.X_OK) and not os.path.islink(filepath):
-            with open(filepath) as f:
-                return f.read(2) != "#!"
+            with open(filepath, 'r', encoding="ascii", errors="surrogateescape") as f:
+                return (f.read(2) != "#!")
 
     def is_unix_library(filepath):
         # Whether a file is really a library and not a symlink (unix only)
@@ -183,5 +183,5 @@ def fix_rpaths(path, qt_deploy_path, qt_install_info, chrpath=None):
     for dirpath, dirnames, filenames in os.walk(path):
         for filename in filenames:
             filepath = os.path.join(dirpath, filename)
-            if is_unix_executable(filepath) or is_unix_library(filepath):
+            if (is_unix_executable(filepath) or is_unix_library(filepath)):
                 fix_rpaths_helper(filepath)

3. scripts/packageIfw.py

Code: Select all

$ git diff scripts/packageIfw.py
diff --git a/scripts/packageIfw.py b/scripts/packageIfw.py
index 7a38204311..96adeaaa31 100755
--- a/scripts/packageIfw.py
+++ b/scripts/packageIfw.py
@@ -36,7 +36,7 @@ import shutil
 import inspect
 
 def usage():
-    print('Usage: %s [-v|--version-string=versionstring] [-d|--display-version=versionstring] [-i|--installer-path=/path/to/installerfw] [-a|--archive=archive.7z] [--debug] <outputname>' %  os.path.basename(sys.argv[0]))
+    print('Usage: %s [-v|--version-string=versionstring] [-d|--display-version=versionstring] [-i|--installer-path=/usr/local] [-a|--archive=archive.7z] [--debug] <outputname>' %  os.path.basename(sys.argv[0]))
 
 def substitute_file(infile, outfile, substitutions):
     with open(infile, 'r') as f:

4. src/libs/utils/mimetypes/mimeprovider.cpp

Code: Select all

$ git diff src/libs/utils/mimetypes/mimeprovider.cpp
diff --git a/src/libs/utils/mimetypes/mimeprovider.cpp b/src/libs/utils/mimetypes/mimeprovider.cpp
index 562ef7e3e3..413324e17c 100644
--- a/src/libs/utils/mimetypes/mimeprovider.cpp
+++ b/src/libs/utils/mimetypes/mimeprovider.cpp
@@ -802,7 +802,8 @@ void MimeXMLProvider::ensureLoaded()
 
 //        if (!fdoXmlFound) {
 //            // We could instead install the file as part of installing Qt?
-            allFiles.append(QLatin1String(":/qt-project.org/qmime/freedesktop.org.xml"));
+            // allFiles.append(QLatin1String(":/qt-project.org/qmime/freedesktop.org.xml"));
+            allFiles.append(QLatin1String("/usr/share/mime/packages/freedesktop.org.xml"));
 //        }
 
         if (m_allFiles == allFiles)


There might be some other modifications .... Well....
Anyway, I'm running OpenMV IDE 2.0.0, with full functionalities, using an OpenMV3 R2 (I think it's STM32F765).


Let me know when you'll be on kickstarter, and I even purchased your wifi shield just now.


Questions:
A. What is the NEWEST firmware version? My built OpenMV comes with firmware 2.9.0, but the IDE keeps informing me to upgrade to a NEWER version? I think I'm using the NEWEST OpenMV firmware already...
B. I'm expecting a lot more functionalities, like: contour, dilate, etc... Have you done that? If done, can you please show me the doc?

Thank you ...
Pei
Welcome to Longer Vision
http://www.longervision.ca
User avatar
kwagyeman
Posts: 2286
Joined: Sun May 24, 2015 2:10 pm

Re: Python3 compatible OpenMV-IDE ...

Postby kwagyeman » Wed Jul 18, 2018 9:13 pm

The newest version is 3.0.0.

1. We already support dilate and erode. https://docs.openmv.io/library/omv.imag ... age.dilate That's been there forever. We support find blobs for blob finding. We do not support contour finding. The reason for this was a lot of our stack was developed for the M4 which has extremely limited memory and contours require you to store a list of points per color region versus a fixed sized struct like find_blobs() returns. Unless you need the shape of the blob you don't need find contours. Even then, with CNNs using any of the old OpenCV techniques isn't the best use of time. For example, after finding a color blob which find_blobs returns you can use a CNN to determine what's going on under that blob.

...

As for adding contours... the return on investment for me doing this isn't there. If you'd like it you can always edit the C code. Any major new feature expansions will be on ML CNN support. Moving forwards me and Ibrahim want to avoid trying to "put openCV on a microcontroller" and instead want to just support deep learning on it and be able to run models trained with a desktop CPU.

The reason for this is to avoid endless feature creep that we are the bottleneck to support. Please understand when we started the OpenMV Cam project the goal was just to create a programmable color tracking sensor. In particular, if you look at our product in regards to the CMUCam1/2/3/4 and the Pixy (CMUcam5) we use the exact same type of blob detection technique and we were just trying to make the sensor more useful. It was never our goal to be OpenCV. However, because we had firmware space we added a lot more features in response to customer demands. We're trying to scale that back now. It's not possible for 2 guys in their free time to adding new features endlessly. Deep learning support is the best way we can scale functionality without being the limiter on it.

...

As for your OpenMV IDE issues. Have you followed this:

$ git clone --recursive https://github.com/openmv/openmv-ide.git
$ cd openmv-ide
$ ./make.py

... because you should be on the openmv branch of the qtcreator repo.
Nyamekye,
User avatar
jiapei100
Posts: 33
Joined: Fri Oct 14, 2016 7:07 pm
Contact:

Re: Python3 compatible OpenMV-IDE ...

Postby jiapei100 » Thu Jul 19, 2018 4:42 am

kwagyeman wrote:
Wed Jul 18, 2018 9:13 pm

The newest version is 3.0.0.

1. We already support dilate and erode. https://docs.openmv.io/library/omv.imag ... age.dilate That's been there forever. We support find blobs for blob finding. We do not support contour finding. The reason for this was a lot of our stack was developed for the M4 which has extremely limited memory and contours require you to store a list of points per color region versus a fixed sized struct like find_blobs() returns. Unless you need the shape of the blob you don't need find contours. Even then, with CNNs using any of the old OpenCV techniques isn't the best use of time. For example, after finding a color blob which find_blobs returns you can use a CNN to determine what's going on under that blob.

...

Thank you ... testing it...

kwagyeman wrote:
Wed Jul 18, 2018 9:13 pm

As for adding contours... the return on investment for me doing this isn't there. If you'd like it you can always edit the C code. Any major new feature expansions will be on ML CNN support. Moving forwards me and Ibrahim want to avoid trying to "put openCV on a microcontroller" and instead want to just support deep learning on it and be able to run models trained with a desktop CPU.

The reason for this is to avoid endless feature creep that we are the bottleneck to support. Please understand when we started the OpenMV Cam project the goal was just to create a programmable color tracking sensor. In particular, if you look at our product in regards to the CMUCam1/2/3/4 and the Pixy (CMUcam5) we use the exact same type of blob detection technique and we were just trying to make the sensor more useful. It was never our goal to be OpenCV. However, because we had firmware space we added a lot more features in response to customer demands. We're trying to scale that back now. It's not possible for 2 guys in their free time to adding new features endlessly. Deep learning support is the best way we can scale functionality without being the limiter on it.

...
kwagyeman wrote:
Wed Jul 18, 2018 9:13 pm

As for your OpenMV IDE issues. Have you followed this:

$ git clone --recursive https://github.com/openmv/openmv-ide.git
$ cd openmv-ide
$ ./make.py

... because you should be on the openmv branch of the qtcreator repo.
Yes, that is what I've done.... However, git status directly from the folder under openmv-ide

Code: Select all

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

        modified:   qt-creator (new commits, modified content)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
git status won't be able to show which files are of differences...
Welcome to Longer Vision
http://www.longervision.ca
User avatar
kwagyeman
Posts: 2286
Joined: Sun May 24, 2015 2:10 pm

Re: Python3 compatible OpenMV-IDE ...

Postby kwagyeman » Fri Jul 20, 2018 12:56 am

Oh, just cd into qtcreator and do git status again.
Nyamekye,
User avatar
jiapei100
Posts: 33
Joined: Fri Oct 14, 2016 7:07 pm
Contact:

Re: Python3 compatible OpenMV-IDE ...

Postby jiapei100 » Fri Jul 20, 2018 10:53 pm

Yes, that was what I've done...

Code: Select all

$ git status
HEAD detached from dde6ea1176
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   scripts/common.py
        modified:   scripts/packageIfw.py
        modified:   src/libs/utils/mimetypes/mimeprovider.cpp


The problem is, where can I pull request? I failed to pull request many times already...


kwagyeman wrote:
Fri Jul 20, 2018 12:56 am
Oh, just cd into qtcreator and do git status again.
Welcome to Longer Vision
http://www.longervision.ca
User avatar
kwagyeman
Posts: 2286
Joined: Sun May 24, 2015 2:10 pm

Re: Python3 compatible OpenMV-IDE ...

Postby kwagyeman » Sat Jul 21, 2018 12:17 am

If you forked my repo then you'll be able to create a pull request:

https://help.github.com/articles/about-pull-requests/
Nyamekye,

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 4 guests