I asked about the directory of the previous image file.
But is my recognition incorrect and sending JPEG data via USB is wrong?
If my recognition is correct I was thinking that it can be checked on a serial monitor, but I can not confirm it.
Please tell me how you are sending camera data
Thank you
Hi, the camera sends a JPEG data stream over serial to the computer. You can use these scripts to see our protocol:
#!/usr/bin/env python2
# This file is part of the OpenMV project.
#
# Copyright (c) 2013-2021 Ibrahim Abdelkader <iabdalkader@openmv.io>
# Copyright (c) 2013-2021 Kwabena W. Agyeman <kwagyeman@openmv.io>
#
# This work is licensed under the MIT license, see the file LICENSE for details.
#
# An example script using pyopenmv to grab the framebuffer.
import sys
import numpy as np
import pygame
import pyopenmv
from time import sleep
script = """
# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!
This file has been truncated. show original
#!/usr/bin/env python2
# This file is part of the OpenMV project.
#
# Copyright (c) 2013-2021 Ibrahim Abdelkader <iabdalkader@openmv.io>
# Copyright (c) 2013-2021 Kwabena W. Agyeman <kwagyeman@openmv.io>
#
# This work is licensed under the MIT license, see the file LICENSE for details.
#
# Openmv module.
import struct
import sys,time
import serial
import platform
import numpy as np
from PIL import Image
__serial = None
__FB_HDR_SIZE =12
This file has been truncated. show original
If you need robust multi-platform code then you’d have to look at how our IDE does it which is much more battle hardened.
Thank you for your quick response
I compiled pyopenmv.py
ImportError: no module named ‘serial’ occurs
Other errors also occur
I think that there are missing files or misconfiguration
Please point out.
Hi,
sudo pip install pyserial
That’s said, have you run python programs on a Linux device before? You may wish to reference some tutorial stuff. Using those scripts is for advanced users who know what they are doing.
Thank you for your reply
I did it according to your advice
python test2.py
The compile error no longer occurred when I ran it.
Use version python 37-32 (windows 7ver.)
However, on Open MV IDE
ImportError: no module named ‘serial’
Has occurred
Please tell me the setting of Open MV IDE
Thank you
Those script aren’t runnable in OpenMV IDE. They are designed to be run on the linux computer by CPython.
Thank you for your support
As you gave me advice
Running two files on Ubuntu on Linux
I was able to display the camera image.
But serial data stream
I have not confirmed until
Please advice again.
Thank you
Hi, you can dump the serial data stream by using this code:
Just execute it in the loop:
def enable_fb(enable):
__serial.write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_FB_ENABLE, 4))
__serial.write(struct.pack("<I", enable))
def arch_str():
__serial.write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_ARCH_STR, 64))
return __serial.read(64).split('\0', 1)[0]
if __name__ == '__main__':
if len(sys.argv)!= 3:
print ('usage: pyopenmv.py <port> <script>')
sys.exit(1)
with open(sys.argv[2], 'r') as fin:
buf = fin.read()
disconnect()
init(sys.argv[1])
stop_script()
exec_script(buf)
See the 3 lines.