title: Streamlit: How to store value of variable in cache
body: <p>I am using 2 differnt radio options for performing different tasks. I want to capture image form one and then do some operation later in the option 2. When I try to change the radio option to 2 after storing a frame in <code>my_image</code> (in the option 1), there comes an error in thre streamlit <code>NameError: name 'my_image' is not defined</code>. I was thinking that it can be done by storing the variable <code>my_image</code> in cache but I don't know how to do this. Is there any other way to do this.</p>
  <pre><code>import streamlit as st
  import cv2
  
  def Camera():
      frames1 = st.empty()
      button1 = st.button('DONE', key=0)
      while cap.isOpened():
          frames1.image(cap.read()[1], channels=&quot;BGR&quot;)
          if button1:
              my_image = cap.read()[1]
              cap.release()
              break
      return my_image
  
  option = st.sidebar.radio('Choose the option', [1, 2])
  
  if option == 1:
      cap = cv2.VideoCapture(0)
  
      my_image = Camera()
      st.image(my_image, channels=&quot;BGR&quot;)
  
  if option == 2:
      st.image(my_image, channels='BGR')
  </code></pre>