Plaba
March 4, 2020, 11:11pm
1
Hello! I’m rather new to OpenMV, and I’m writing a Java application that connects to the OpenMV by a serial port.
I noticed that the OpenMV IDE was capable of receiving both the frames that the OpenMV captured, and at the same time receiving the uninterrupted output of the program. What would I need to do to replicate that behavior between a Java application and the OpenMV?
You need to port this:
#!/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
And there’s an example that uses that module to execute a script and read the framebuffer:
#!/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
Plaba
March 5, 2020, 3:25am
3
Thanks for your reply!
I’ve already ported the script to Java. It’s available at GitHub - entech281/JOpenMV: Java code to manage an OpenMV camera. .
My problem is that I need to use the serial port for other data as well. What would I need to do not have the frame data and the other data print at the same time and get mixed together?
Hi, this uses the debug mode so they are already not mixed.
Plaba
March 6, 2020, 7:49pm
5
Thanks a lot!
After a little digging, I figured out that I need to use the tx_buf API call to read the output of the program.
Thanks for your help!
Yes that’s right, you just need the tx_buf_len and tx_buf commands.