Changing directory path

General discussion about topics related to OpenMV.
SARAVANABAVAN
Posts: 32
Joined: Thu May 10, 2018 12:19 am
Location: Karaikal

Changing directory path

Postby SARAVANABAVAN » Thu Jun 07, 2018 12:07 am

Hello sir,
I need to change the path or directory of the Openmv cam to save the files ??? What is the procedure to change it ??? (i.e) If I'm taking the picture in openMV CAM it is saved in openmv cam's memory card slot... How can i change the path to save the captured image in the computer or any other external device ...???
User avatar
kwagyeman
Posts: 2118
Joined: Sun May 24, 2015 2:10 pm

Re: Changing directory path

Postby kwagyeman » Thu Jun 07, 2018 2:28 am

You can't save a file to an external device without writing code to transfer that file to said external device. Saving pictures is done to the SD card only.
Nyamekye,
SARAVANABAVAN
Posts: 32
Joined: Thu May 10, 2018 12:19 am
Location: Karaikal

Re: Changing directory path

Postby SARAVANABAVAN » Thu Jun 07, 2018 2:48 am

May I know the procedure to write the coding to change the path into external card of the Raspberry pi instead of saving it in the external SD card attached to the OpenMV CAM ???
User avatar
kwagyeman
Posts: 2118
Joined: Sun May 24, 2015 2:10 pm

Re: Changing directory path

Postby kwagyeman » Thu Jun 07, 2018 3:07 am

Hi, how is the OpenMV Cam connected to the Pi? Via a USB cable? Serial port? If via the USB cable just do:

print(img.compress(), end='')

This will send the image data out to the Pi as a byte stream to any program that opens the serial port. Note... don't do this using OpenMV IDE as it won't understand what to do with that raw byte data.
Nyamekye,
SARAVANABAVAN
Posts: 32
Joined: Thu May 10, 2018 12:19 am
Location: Karaikal

Re: Changing directory path

Postby SARAVANABAVAN » Thu Jun 07, 2018 3:17 am

Thank you sir...
SARAVANABAVAN
Posts: 32
Joined: Thu May 10, 2018 12:19 am
Location: Karaikal

Re: Changing directory path

Postby SARAVANABAVAN » Thu Jun 07, 2018 7:44 am

Hello sir,
Sorry for asking again and again... But here we are going to connect the camera with Raspberry pi by the UART... Then how we can change the path or directory to save the snapshot which was taken in the camera???
OutoftheBOTS
Posts: 87
Joined: Tue May 29, 2018 4:15 am

Re: Changing directory path

Postby OutoftheBOTS » Thu Jun 07, 2018 4:41 pm

UART isn't a directory rather a communication peripheral.

Rather trying to save to the UART you will need to send the image data over UART to the RPi then the RPi will need a program running that reads this data from UART then saves it to it's storage.
SARAVANABAVAN
Posts: 32
Joined: Thu May 10, 2018 12:19 am
Location: Karaikal

Re: Changing directory path

Postby SARAVANABAVAN » Fri Jun 08, 2018 12:32 am

Hello sir,
That's the thing I'm asking... What is the procedure to send the data to the Raspberry pi ??? For example if i took photo in OpenMV CAM , i'm having a option to change the path to save the data to the directory in the external memory card... But the problem is that it is not saving ... But it is capturing...
SARAVANABAVAN
Posts: 32
Joined: Thu May 10, 2018 12:19 am
Location: Karaikal

Re: Changing directory path

Postby SARAVANABAVAN » Mon Jun 11, 2018 7:09 am

Hello sir,
Here I'm getting the values of x,y,z from the OpenMV CAM ... And I'm sending this to the raspberry pi thorugh UART as an array of data which will be containing the values of x,y,z... And after the values which have been sent to the raspberry pi , the raspberry pi have to order the tool to pick in the desired position as per the array... So what is procedure to write the program for the raspberry pi to read the data ??? (i.e) How can the raspberry pi reads the data which is sent as array of x,y,z values by the OpenMV CAM through UART ???
OutoftheBOTS
Posts: 87
Joined: Tue May 29, 2018 4:15 am

Re: Changing directory path

Postby OutoftheBOTS » Mon Jun 11, 2018 7:31 am

Ok it is going to depend upon how you encode the data at the OpenMV cam end to how the data needs to decoded at the RPi end.

Probably the most common used methods for encoding data to be sent over UART in python is json, pickle or struct. A google search will explain each of them :)

I mainly use struct (micropython version is called ustruct) as it is the most efficient way but probably for most the hardest to understand as it uses primitive data type.

This will give you an idea of whatr code is needed at OpenMV cam end

Code: Select all

from ustruct import pack
import pyb
uart = pyb.UART(3, uart_baudrate, timeout_char = 1000) #set the needed baud rate
array_data (50, 200, 36, 29) #msome made up data 
enocded_data = pack('HHHH', array_data) #encode the data as unsigned short int
uart.write(data)
This will give you an idea of code needed at RPi end

Code: Select all

from struct import unpack
import serial
ser = serial.Serial ("/dev/ttyAMA0")    #Open named port 
ser.baudrate = uart_baudrate                   #Set the needed baud rate
encoded_data = ser.read(8)  #need 8 bytes to match the 4 unsigned ints that was sent
array_data = unpack('HHHH', encoded_data)
SARAVANABAVAN
Posts: 32
Joined: Thu May 10, 2018 12:19 am
Location: Karaikal

Re: Changing directory path

Postby SARAVANABAVAN » Tue Jun 12, 2018 1:11 am

Hi sir,
Sorry for asking again... But the problem is that the raspberry pi is not able to run the program which was sent by the openmv cam ... Is there any alternate solution which is able to run the program which was sent by the openmv cam...??? I'm asking the alternate for the raspberry pi which is able to receive the array of values which was sent by the openmv cam ... Thanks in advance...

Return to “General Topics”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests