<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="372936" data-post-id="372936">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="alvises" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alvises/120/2247_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  alvises
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just made this screencast showing how to run object detection models on Nerves + Rpi5 + Hailo8L with the NxHailo library.</p>
<div class="youtube-onebox lazy-video-container" data-video-id="eYamm3CEH9c" data-video-title="Nerves powered Vision - Deploy YOLOv8 on RPi5 with Hailo8L" data-video-start-time="" data-provider-name="youtube">
  <a href="https://www.youtube.com/watch?v=eYamm3CEH9c" target="_blank" class="video-thumbnail" rel="noopener nofollow ugc">
    <img class="youtube-thumbnail" src="https://img.youtube.com/vi/eYamm3CEH9c/maxresdefault.jpg" title="Nerves powered Vision - Deploy YOLOv8 on RPi5 with Hailo8L" width="690" height="388">
  </a>
</div>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="372936" data-batch-url="/posts/batch_likers">
                        6
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/nerves-rpi5-hailo8-m-2-ai-module-support/68142/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-372936" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="372936"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="379032" data-post-id="379032">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="alfredfriedrich" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alfredfriedrich/120/8256_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  alfredfriedrich
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I recreated your demo from the last Nerves EU Meetup, using your <a href="https://github.com/poeticoding/nx_hailo/tree/main/nx_hailo/livebooks" rel="noopener nofollow ugc">livebooks</a> as reference. I am running Phoenix on top of it instead of livebook to display the camera picture and I am getting realtime images from the camera if I run it without inference.</p>
<p>But with inference (which takes around 75ms) the delay adds up too much to be of any use.</p>
<p>Any idea on how to debug this further? My setup is pretty much the same, calling <code>NxHailo.Hailo.infer</code> which calls the NIF which calls the <a href="https://github.com/poeticoding/nx_hailo/blob/main/nx_hailo/c_src/nx_hailo.cpp" rel="noopener nofollow ugc">C source</a>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="379032" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/nerves-rpi5-hailo8-m-2-ai-module-support/68142/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-379032" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="379032"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="379052" data-post-id="379052">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lawik" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lawik/120/32028_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lawik
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Nerves Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Does this mean you are performing the inference before displaying the image? It sounds like it.</p>
<p>There are many ways of making these things more or less performant. I would try a fairly simple one which is to display the image immediately and do the inference in parallel. It may trail a bit but you get the image immediately. And Livebook can draw bounding boxes for you.</p>
<p>If you can pull the image from the camera at a smaller resolution than what you display for inference that would reduce the amount of processing. That will also matter assuming the camera can keep up or deliver multiple streams.</p>
<p>The next thing I would look at is reducing any extra copies for the inference part. I believe evision can pull the data directly into an Nx data structure. Hopefully that is already being used. I haven’t looked at the details.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="379052" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/nerves-rpi5-hailo8-m-2-ai-module-support/68142/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-379052" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="379052"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="379071" data-post-id="379071">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="alfredfriedrich" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alfredfriedrich/120/8256_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  alfredfriedrich
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hallo lawik ,</p>
<p>thanks you for your reply. Yes, the LiveView recieves a message with the camera frame (640x360@25fps) and processes it with the NIF. The detected objects are the drawn onto the image frame, base64 encoded and then assigned to the  source in the LiveView.</p>
<p>For now I have implemented frame dropping, and this gets me around 11-13 fps.</p>
<p>I also tried to display the frames without processing, when it already processes the frame before, instead of dropping it, but this resulted in a flicker effect and was not watchable.</p>
<p>And yes, Evision.Mat.to_nx() is used before the Hailo code is called and I also timed the 3 steps preproc (resize, convert to Nx,..), inference and postproc (draw boxes) and inference takes around 70ms here.</p>
<p>I am not sure I understand fully your suggestion regarding displaying the unprocessed frame immediately and assigning the processed frame after inference has completed, as there would have been already another (newer) frame be displayed. With 25 fps I have 40ms max for converting, inference and displaying a single frame.</p>
<p>Right now 10+ fps is a good starting point for me, but I will look more into the Hailo docs and sources and also trying different resolutions and checking my Nx setup.</p>
<p>Edit: using the <code>yolo8s</code> model instead of the <code>yolo8m</code> gives me around 18fps (I am using the Hailo-8L chip).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="379071" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/nerves-rpi5-hailo8-m-2-ai-module-support/68142/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-379071" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="379071"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="379133" data-post-id="379133">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="lawik" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lawik/120/32028_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  lawik
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Nerves Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You could perform inference at ~14 fps with that level of performance. You can still show video at a high level of fps.</p>
<p>But only grab a new frame for inference when the inference has completed on the previous one. If you use LiveView or another side-channel to control bounding boxes in the UI you don’t have to draw them on the image and you can show the unprocessed image but update bounding boxes at ~14 fps while the video rolls at a normal frame rate.</p>
<p>This means the bounding boxes shown are up to 70ms out of sync but I’m not sure that’s even noticeable. So don’t delay the image, only delay the inference result. Let me know if I’m not making sense <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>Certainly better if you can run it faster. But I don’t know the inference bits particularly well.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="379133" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/nerves-rpi5-hailo8-m-2-ai-module-support/68142/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-379133" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="379133"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="379969" data-post-id="379969">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="alfredfriedrich" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alfredfriedrich/120/8256_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  alfredfriedrich
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hello Lars,</p>
<p>sorry I did not reply earlier, to be honest I did not understand it fully, and my RPi / HailoAI project got interrupted by YASP - Yet Another Side Project <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p>
<p>I re-read your post just now, and suddenly you make perfectly sense to me. I mean I’m not sure if it fits for a fast-moving/changing video, but I want to try out at least your idea and see how it performs. Regarding your idea of displaying a high resolution picture than using for inference, this xould also be dynamically adjusted at runtime, e.g. if the performance drops below 10fps, I could switch to a lower resolution. I like that!</p>
<p>It will be some time till I can tinker with it again, I will post about it in the forum when I finally tried it out.</p>
<p>Thank you again for the clarification and the ideas.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="379969" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/nerves-rpi5-hailo8-m-2-ai-module-support/68142/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-379969" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="379969"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="382886" data-post-id="382886">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Vidar" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Vidar
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I made a setup with the Raspberry 5 and the Hailo-8 (26 tops) including discovery and control of a GigE camera. I get about 14 frames per second interference rate using 640x640 RGB8 resolution with YOLOv8n.</p>
<p>The heavy frame processing and encoding are all Rust NIFs that run in parallel: Receiving the GigE camera packets and color converting them before assembly into full frames directly inside a ring buffer. No copying of anything. The ring buffer then feeds three other processes: 1. A 24fps encoder MJpeg stream with low latency which uses the pictures as feedback for a physical control setup. 2. A 24fps Rust H264 encoder that feeds a Membrane HLS web stream (with higher latency) for remote user viewing. And 3. Whenever the interference asks for it a frame is grabbed from the ring buffer, resized, and turned into an NX tensor for interference.</p>
<p>All user facing UI and controls are Phoenix Liveview based. The 24fps video rates could certainly be faster, but we have no need for more and less power use and heat is positive.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="382886" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/nerves-rpi5-hailo8-m-2-ai-module-support/68142/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-382886" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="382886"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>