Python3 compatible OpenMV-IDE ...

Besides all print “XXX” to print (“XXX”), there are still a bunch of modifications need to be done…

$ 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

Um, PR to the github?

I’ve already made openmv-ide be compatible with Python3 on my computer, but failed to pull request as shown in qt-creator pull request? · Issue #25 · openmv/openmv-ide · GitHub .
A lot of my modifications are under folder qt-creator GitHub - openmv/qt-creator at dde6ea117694d7ac3c7ab8577e24c8b586538e6c .

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
$ 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>
  1. scripts/common.py
$ 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. scripts/packageIfw.py
$ 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:
  1. src/libs/utils/mimetypes/mimeprovider.cpp
$ 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

The newest version is 3.0.0.

  1. We already support dilate and erode. image — machine vision — MicroPython 1.15 documentation 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 GitHub - openmv/openmv-ide: QtCreator based OpenMV IDE
$ cd openmv-ide
$ ./make.py

… because you should be on the openmv branch of the qtcreator repo.

Thank you … testing it…




Yes, that is what I’ve done… However, git status directly from the folder under openmv-ide

$ 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…

Oh, just cd into qtcreator and do git status again.

Yes, that was what I’ve done…

$ 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…



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

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