LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling an image file without a fixed browse path

Solved!
Go to solution

Hi, I know how to pull an image into my labview program by using a fixed browse path. However, I need the program along with the image to be usable in other computers i.e., browse path will not be constant. How can I do this without making a change in my block diagram every time the program moves to a different computer?

 

Thanks! 

0 Kudos
Message 1 of 10
(1,820 Views)

A file path control on your front panel ?? !!

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
Learn LabVIEW

0 Kudos
Message 2 of 10
(1,807 Views)

Hi RavensFan, thank you for the reply! I apologize for not clarifying in my original post: I know I can have a file path constant on my front panel, but I was hoping I can create a more advanced way of doing this i.e., like a floating reference in a zip file or something. I need the image the basically pop up along with the LabVIEW exe file, if it is at all possible?

 

I will keep the file path constant on my front panel idea as a Plan B! 

 

0 Kudos
Message 3 of 10
(1,800 Views)

Or perhaps something to do with getting the image as an array, and then copying this array as an input to a Array to Image function? Though, sounds like it will take forever to input each digit from the image into the new array. :S

0 Kudos
Message 4 of 10
(1,799 Views)

@hookemhorns wrote:

Hi RavensFan, thank you for the reply! I apologize for not clarifying in my original post: I know I can have a file path constant on my front panel, but I was hoping I can create a more advanced way of doing this i.e., like a floating reference in a zip file or something. I need the image the basically pop up along with the LabVIEW exe file, if it is at all possible?

 

I will keep the file path constant on my front panel idea as a Plan B! 

 


Let's fix some terminology.  There is no such thing as a file path constant on the front panel.  Constants only exist on the block diagram.  Controls exist on the front panel which allows the user to select the file to use.

 

"Floating reference in a zip file".  I have no idea what you mean by that.

 

"I need the image the basically pop up along with the LabVIEW exe file,"  Are you trying to say the image file you want to open happens to exist in the same directory as the executable?  In the File I/O >> File Constants directory is a subVI call Get System Directory that will return the file path to various paths of interest such as application directory or user documents directory or others.  You can use that to help build a path to a specific file where the actual name of the directory may vary from PC to PC or user to user.

 


@hookemhorns wrote:

Or perhaps something to do with getting the image as an array, and then copying this array as an input to a Array to Image function? Though, sounds like it will take forever to input each digit from the image into the new array. :S


Not completely sure what you are explaining here.  Are you trying to think of a way to store the image in your VI without it being read from a file?  It sounds like you are trying to key in the data byte by byte.

 

If that is what you are thinking, that is crazy.  Is this picture something that is always the same, no matter what the actual PC it is stored in?

 

You can save images as pictures in the block diagram.  Look into the Graphics and Sounds palette.  If you load an image from file and save it to a picture indicator, you can then right click on that indicator and create or change that into a constant.  That constant on the block diagram can be wired to a picture indicator.  You can have a few constants if you need to change the picture depending on conditions.

 

Here is an example for a front panel that I wanted an arrow depending on which way the motor was spinning.

 

Message 5 of 10
(1,780 Views)

To get a file location when the path is unknown - If I recall I use "current vis path" and then "strip path" in a for loop until "name" is the folder I want to access.  This is assuming the folder is at a higher level then the folder that the vi is in

 

----------------------------------------------------
Studying for CLA.
LabVIEW, inherit from social media habits!
0 Kudos
Message 6 of 10
(1,756 Views)

"Application directory" works great for projects and executables. It's less messy that Current VI Path, but slightly different functionality. If you store the image next to the VI, Current VI Path makes more sense. But you'd need a different tactic for the exe.

 

Build path can string paths as well. If you build "C:\foo" with "..\bar.txt", the result will be "C:\bar.txt". Each "..\" string a path.   

Message 7 of 10
(1,729 Views)

Hi RavensFan,

 

Thank you for your input! Yes, I intend to have the same picture from PC to PC. I have the block diagram ready, but the image file I am trying to call out when the program runs is fixed to my local desktop. I believe the easiest way to do it based on your reply is to have the picture on my block diagram. However, I tried copying and pasting the image on my block diagram, but could not paste it as an indicator. When I right-click on the image in my block diagram, the only options are "Original Size" and "Properties". 

 

Do you know how exactly I may have it show up as an indicator?

 

*Edit: I was able to create an empty picture constant, but no idea how to use a .jpg file I already have and use it as a constant in my code.

 

hookemhorns_0-1599946886110.png

 

Once again, thanks for all your help!!

0 Kudos
Message 8 of 10
(1,705 Views)
Solution
Accepted by topic author hookemhorns

You missed reading the part where I said you can read the image from the file.

 

It goes like this.

 

 

 

Message 9 of 10
(1,696 Views)

RavensFan, 

 

What would I do without you?! Thank you so much! I learned something new 🙂 

Message 10 of 10
(1,677 Views)