Electronically Assisted Astronomy with a Jetson Nano

Hello,

i have released a new version of JetsonSky. V17_03.

I hope the bugs are ok now.

Alain

Hello,

i have installed a SSD with the AGX Orin in order to make write speed tests when saving a video.

When i use compressed video format, i get lag with many frames lost (4K or even fullHD resolution). So openCV is not really great for compressed videos.

If i use uncompressed format (RAW video), things are better.

So, i will see if i can get more efficient saving routine.

Thommy, you were right ! We’ve got a problem.

Alain

It may not be opencv, but using FFMPEG videio backend that runs on CPU.
You may leverage HW encoding using Gstreamer backend instead (assuming that your opencv library was built with Gtreamer support):

def video_capture() :
    global image_traitee,start_video,nb_cap_video,nb_acq_video,labelInfo1,flag_cap_video,video_path,val_nb_capt_video,videoOut,echelle11
    if nb_cap_video == 1 :
        if flag_filter_wheel == True:
            nom_video = start_video.strftime('VID%Y%m%d_%H%M%S') + '_F' + "%01d" % fw_position + '.avi'
        else :
            nom_video = start_video.strftime('VID%Y%m%d_%H%M%S') + '.avi'
        filePath = os.path.join(video_path,nom_video)
        if image_traitee.ndim == 3 :
            height,width,layers = image_traitee.shape
            if flag_HQ == 0 :
                gst_pipe = "appsrc ! video/x-raw,format=BGR,width=" + str(width) + ",height=" + str(height) + ",framerate=25/1 ! queue ! videoconvert ! video/x-raw,format=BGRx ! nvvidconv ! nvv4l2h264enc ! h264parse ! avimux ! filesink location=" + filePath
            else :
                gst_pipe = "appsrc ! video/x-raw,format=BGR,width=" + str(width) + ",height=" + str(height) + ",framerate=25/1 ! queue ! avimux ! filesink location=" + filePath      
        else :
            height,width = image_traitee.shape
            if flag_HQ == 0 :
                gst_pipe = "appsrc ! video/x-raw,format=GRAY8,width=" + str(width) + ",height=" + str(height) + ",framerate=25/1 ! queue ! videoconvert ! video/x-raw,format=BGRx ! nvvidconv ! nvv4l2h264enc ! h264parse ! avimux ! filesink location=" + filePath
            else :
            	gst_pipe = "appsrc ! video/x-raw,format=GRAY8,width=" + str(width) + ",height=" + str(height) + ",framerate=25/1 ! queue ! avimux ! filesink location=" + filePath
            	
        videoOut = cv2.VideoWriter(gst_pipe, cv2.CAP_GSTREAMER, 0, float(25), (width, height), isColor = (image_traitee.ndim > 1))
        
        labelInfo1.config(text = "                                                                                                        ") 
        labelInfo1.config(text = " Acquisition vidéo en cours")
        
    if nb_cap_video <= val_nb_capt_video -2 :
        if nb_cap_video > 5 :
            if image_traitee.ndim == 3 :
                #videoOut.write(cv2.cvtColor(image_traitee, cv2.COLOR_BGR2RGB))
                videoOut.write(image_traitee)
            else :
                videoOut.write(image_traitee)
        if nb_cap_video % 10 == 0 :
            labelInfo1.config(text = " frame : " + str (nb_cap_video) + "                                       ")
        nb_cap_video += 1
    else :
        videoOut.release()
        flag_cap_video = False
        labelInfo1.config(text = " Acquisition vidéo terminee     ")

Thank you Sir :-)
Never the less, I have bought an SSD also and it is big enough to record uncompressed. I will do my research. But for now, we have cloudy sky
have cloudy sky
and so on.
I’m happy that you will look into that.

Best
Thommy

Hello Honey_Patouceul,

many thx !

I tried this :

def video_capture() :
    global image_traitee,start_video,nb_cap_video,nb_acq_video,labelInfo1,flag_cap_video,video_path,val_nb_capt_video,videoOut,echelle11,flag_pause_video,timer1,val_deltat,FDIF,flag_FDIF
    if nb_cap_video == 1 :
        if flag_filter_wheel == True:
            nom_video = start_video.strftime('VID%Y%m%d_%H%M%S') + '_F' + "%01d" % fw_position + '.avi'
        else :
            nom_video = start_video.strftime('VID%Y%m%d_%H%M%S') + '.avi'
        path_video = video_path+nom_video
        print(path_video)
        if image_traitee.ndim == 3 :
            height,width,layers = image_traitee.shape
            if flag_HQ == 0 :
               gst_pipe = "appsrc ! video/x-raw,format=BGR,width=" + str(width) + ",height=" + str(height) + ",framerate=25/1 ! queue ! videoconvert ! video/x-raw,format=BGRx ! nvvidconv ! nvv4l2h264enc ! h264parse ! avimux ! filesink location=" + path_video
            else :
               gst_pipe = "appsrc ! video/x-raw,format=BGR,width=" + str(width) + ",height=" + str(height) + ",framerate=25/1 ! queue ! avimux ! filesink location=" + path_video      
        else :
            height,width = image_traitee.shape
            if flag_HQ == 0 :
                gst_pipe = "appsrc ! video/x-raw,format=GRAY8,width=" + str(width) + ",height=" + str(height) + ",framerate=25/1 ! queue ! videoconvert ! video/x-raw,format=BGRx ! nvvidconv ! nvv4l2h264enc ! h264parse ! avimux ! filesink location=" + path_video
            else :
                gst_pipe = "appsrc ! video/x-raw,format=GRAY8,width=" + str(width) + ",height=" + str(height) + ",framerate=25/1 ! queue ! avimux ! filesink location=" + path_video
        print(gst_pipe)
        videoOut = cv2.VideoWriter(gst_pipe, cv2.CAP_GSTREAMER, 0, float(25), (width, height), isColor = (image_traitee.ndim > 1))
        labelInfo1.config(text = "                                                                                                        ") 
        labelInfo1.config(text = " Acquisition vidéo en cours")
    if flag_pause_video == False :
        if time.time() - timer1 >= val_deltat :       
            if nb_cap_video <= val_nb_capt_video :
                if (flag_FDIF == 1 and FDIF > 0) or flag_FDIF == 0 :
                    FDIF = FDIF - 1
                    videoOut.write(image_traitee)
                    if (nb_cap_video % 10) == 0 :    
                        labelInfo1.config(text = " frame : " + str (nb_cap_video) + "                            ")
                    nb_cap_video += 1
            else :
                FDIF = 0
                videoOut.release()
                flag_cap_video = False
                labelInfo1.config(text = " Acquisition vidéo terminee     ")
            timer1 = time.time()
    else :
        labelInfo1.config(text = " PAUSE VIDEO       ")

Considering :
video_path= “D:\Alain\Astro\Soft\PC\Videos”

and considering the file name is created with date and hour.

I get no error message except the the fact the file is maybe created but not in the place i expect it to be created. I guess i get a problem with filesink location=" + path_video

Alain

I only tested that on AGX Orin. Not sure if the pipelines would work on Windows host.
Try changing:

into:

path_video = os.path.join(video_path,nom_video)

as in my post.

I did that first but it does not work. So I tried something else.

I will try to solve this issue a bit later.

Alain

I tried again with :

path_video = os.path.join(video_path,nom_video)

I get no error message, video acquisition counter is counting but the video is not saved on the hard drive. I do not understand what is going wrong.

I will try to see if i can find a solution to this problem.

Alain

It would require that your windows host has gstreamer installed and opencv built with support for it. Check with:

import cv2
print(cv2.getBuildInformation())

and check if it has GStreamer support.

You may also check that the video writer is successfully opened:

videoOut = cv2.VideoWriter(gst_pipe, cv2.CAP_GSTREAMER, 0, float(25), (width, height), isColor = (image_traitee.ndim > 1))
if not videoOut.isOpened():
     print('Failed to open writer')
     ...

Hello HP,

well 
 my opencv does not have gstreamer.

I took the easy way to install opencv on my laptop. I used this site :

https://www.lfd.uci.edu/~gohlke/pythonlibs/

So, i have to compile opencv. Quite boring activity (and a bit long time to compile opencv).

The problem is for people who use JetsonSky with windows. It is a bit hard to ask them to compile opencv. 2 or 3 people in the world use JetsonSky. If i ask them to compile opencv, i guess the number of JetsonSky user will be equal to zero.

I must think about that.

Many thanks for your help. As i did not have error message in JetsonSky, i thought everything was ok. Big mistake !

1 Like

An alternative for installing opencv would be using vcpkg for easier config, but not faster.
May be a bit long at first, as it would build any dependency from source, but it would be easy to configure with many options. I’d suggest to install it on a separate drive with many available space (or you’ll have to delete buildtrees after successful installs), and try a nightly build:

# This would show the available options
vcpkg.exe search opencv4

# Assuming that you have a x64 host and a toolchain for this arch:
vcpkg.exe install opencv4[contrib,cuda,cudnn,eigen,ffmpeg,gstreamer,ipp,jpeg,png,openexr,opengl,opencl,openmp,python,tiff]:x64-windows
1 Like

Thx for this information. I will give it a try but later. For now, I am fed up with JetsonSky so I will take a break for some months.

I will be back when I will have some new things to test or when I will have some interesting results to show.

What’s next ?

Hello,

i will start to concentrate on planetary imaging next year (mainly Moon) and deep sky objects with my Celestron C9.25 which was off for too long time.

This means i will not develop JetsonSky for months, until i have made enough outdoor tests to be able to make interesting upgrade of my software.

As laptop is more useable outdoor than Jetson, i will concentrate my work on laptop under Windows. I will still support Jetson SBC but i will focus my work on Xavier NX in order to be more close to most Jetson users.

I guess that if it’s ok for Jetson Xavier NX, things will be ok for new Jetson Orin Nano. If someone can make tests, it would be great.

Well, that’s all for now.

Alain

Thanks for all that amazing work. Hope to see you again here.
Best Thommy

I will. If I solve some issues, I will post new version. But for now, I will take a little rest and try to make videos of the sky !

Alain

I have just trying something. Near line 3893 there are the code for writing the videos. 25 fps were set. I was playing a bit with the value. If I put 12 instead of 25 in, I get a nice normal time video around 700 recorded frames AND the video is about 60 s length, so real time. (Full HD setting Bin2).
With 4k setting the video is double faster ca 30 s.
I will try how it looks under real conditions in the night, but this is statisfying so far for me. I do not know why, but it seems to work.

Hmm, it doesn’t work so good. In the night it is not working. Ok a bit better, but a little.

You saved video in HQ mode, meaning no video compression or not ?

I tried both. HQ has a very very very huge file size. The little advantage is not worth for me. It depends on the intention.

I am trying to compile opencv with gstreamer but for now, i get issues (Windows system).

Compiling opencv is not really simple and i won’t recommend that for JetsonSky users.

As i said previously, generating a 25fps video will produce an accelerated video ; a kind of timelapse. Setting 25fps video does not mean you will get a normal time video. If it takes 100ms to get a frame, each second in the video will represent 25 * 100ms = 2.5s ; your result video will get a 2.5x time acceleration factor comparing to the real time. If you need 10ms for each frame, each second in the video will represent 25*10ms = 0.25s in the real time. You will get a 4 time slower video.

Alain