Rpc master controller example not running

Hi;
RE: “openMV/tools/rpc/rpc_image_transfer_jpg_streaming_as_controller_device” as listed on GIT, not running
Having a difficult getting the interface program given above in the rpc examples to run. Wondering if anyone has had the same difficulties and what could fix it?
I have tried to get the program running in python 3.1.6 but the pygame library doesn’t like the later release and won’t run. If I use python 2.7, pygame runs fine with displays appearing, images drawn etc. But the rpc library doesn’t seem to like the earlier version of python and flakes out with 2.7 whilst running well on PY3.1.6. I tried backing down the versions on rpc to see if an earlier one will run with 2.7. Nothing doing. went back 4 revs to 0.1.5.
Anyone know the magic version combo here?
Just trying to get examples to run listed in the above git ref.
Stimpy

The RPC library itself works on python 2.7 and 3.5. Either is fine. You may have to update the pygame script. However, I’ve tested the pygame script on 2.7 and 3.5 and it does work.

Hi Kwagyman;
Finally got running on 2.7. 3.5 wasn’t working with any of the pygame examples even.
Anything to worry about adding some line finding in the rpc stream generator cam side?
Stimpy

Nope, that shouldn’t be a problem, just make sure the 1 second timeouts are followed.

Can you be more specific on what timeout you mean? Right now getting nothing back. No data stream when I added the line finding in the stream gen def. Thinking timeout else where?
Stimpy

Code?

Hi Kwagyman;
What does it mean when the cam locks into a high blink rate white lite following download of firmware? Can seem to connect to it anymore?
Stimpy

Won’t do anything but blink. Can I send it back for a refund?

I reloaded firmware half dozen times. 7th time stopped it.
But I now seem to have to reload the firmware everytime I replace the main.py? Very time consuming. Is that normal?

Your main.py is causing a crash, it gets run when the camera starts. So, you need to click the erase flash option in the IDE.

yes, using the RPC library with USB is a pain. I’d recommend using the UART interface with the library and developing with an FTDI USB to serial port before using the USB interface.

Hi Kwagyman;
I attempted to use your interface.schedule_callback() operation but it seems like any slight delay in the interface causes failure. Here is the code I modified for the purpose of finding lines in the local image from the camera.
myImage = sensor.snapshot()
def setMyImage(Image):
global myImage
myImage = Image

def getMyImage():
global myImage
return myImage

def FindMyLines():
for l in getMyImage().find_lines(threshold = 1000, theta_margin = 25, rho_margin = 25):
if (min_degree <= l.theta()) and (l.theta() <= max_degree):
getMyImage().draw_line(l.line(), color = (255, 0, 0))
text = str(l.theta())
setMyImage(getMyImage().draw_string(50,20,text,(255,0,0),4))
################################################################

Call Backs

################################################################

This is called repeatedly by interface.stream_writer().

def stream_generator_cb():
setMyImage(sensor.snapshot())
return getMyImage().compress(quality=90).bytearray()

Transmits a stream of bytes()'s generated by stream_generator_cb to the master device.

def jpeg_image_stream_cb():
interface.stream_writer(stream_generator_cb)

When called sets the pixformat and framesize, and then schedules

frame streaming to start after the RPC call finishes.

data is a pixformat string and framesize string.

def jpeg_image_stream(data):
pixformat, framesize = bytes(data).decode().split(“,”)
sensor.set_pixformat(eval(pixformat))
sensor.set_framesize(eval(framesize))
interface.schedule_callback(jpeg_image_stream_cb)
interface.schedule_callback(FindMyLines)
return bytes()

Register call backs.

interface.register_callback(jpeg_image_stream)

Once all call backs have been registered we can start

processing remote events. interface.loop() does not return.

interface.loop()

This is basically your example slightly modified to keep the snaped image as data for the Myfindlines() operation to work on after the last “slave loop”.
Clues?
Any reason your cam needs a firmware download every time I update Main?
Stimpy

Can you just post the snippet where you think the error is with code tags? See the code formatting option.

Hi Kawgeyman;
In fact, I don’t see the code formatting option.

Here is the code i can get it to run sometimes if I delete the second callback installation for the findlines operation. Strangely sometimes. If I leave it in, total crash. So it appears that I might have time for the image save off, but nothing more.
I was wondering about two pieces of code I see from you.
The first is that ‘slow sync’ PC master. If I slow down the back end loop on the PC side that is making the RPC calls, so does that gives the cam more time? I played with adding delays but nothing seems affected. I still returned no data.
Second, I see that the PC side can support IP comms with some commented out calls. Are there examples of this deployed?

Hi Kwageyman;
My H7 will no longer take a firmware load. Only blinks.
I was serious about sending it back. Something went wrong with it. If you take a look at it forensically, you may be able to see why it failed.
can I return to your Burlington NJ address?
Too bad I was ripped off for a cam. But maybe you’ll learn why it failed.
Stimpy

Hi Kwagyman;
So before I put it in the box for shipping I remembered that I hd had problem with a cracked SD card already and went to check it out. Turns that I just happened top check the properties on it and discovered that it mounted fine on the laptop showing 32GB. On the cam only 5Kb. that’s 5 thousand. Microscopic.
Replaced it in the laptop, scanned and fixed. Nothing. So this SD or your cam has a mounting problem. Windows is not complaining nor fouling.
What do you suggest?
Stimpy

BTW left some screenshots in that other post on USB problems if you want proof.

We don’t have a Burlington NJ address. Where di you buy this camera from?

So this SD or your cam has a mounting problem. Windows is not complaining nor fouling.

Is the card formatted as a FAT16/32 drive?

Hi Kwagyman;
I have 4 different types SD cards here all fault out after I format them fresh and reinstall them in the cam. Windows complains that it needs scanning. Checking the installed card properties always shows 5K memory on the card.
This explains many of the problems I have been seeing with the cam.
I saw a fellow on the site who claimed that the EVO drives work. I will try those. But if I had to make a guess on this problem, I would say that something on the cam side is overwriting the FAT table. If you used a third party SD driver lib, perhaps the problem is there? Have you posted source for your firmware?
Stimpy

Forgot to mention, tried FAT and exFAT as offered by the Win 10 formatter.

We use the best most supported C fat file system library: micropython/lib/oofatfs at 2d09a491914075b500b039dbd397e5f01c539285 · openmv/micropython · GitHub

You should format the cards on windows and then plug into the camera.