Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8395147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:13:34+00:00 2026-06-09T20:13:34+00:00

I am using the following code for video frames to set matrix values with

  • 0

I am using the following code for video frames to set matrix values with some range:

for ( int row = 0, i = 0; row < srcMat.rows; ++row, i ++ )
{
   uchar* p = medianMat.ptr ( row );
   for ( int col = 0, j = 0; col < srcMat.cols; ++ col, j ++ )
   {
     dstMat ( cv::Range::all(), cv::Range ( i * 5 +1, i * 5 + 4 )).setTo ( *p );
     data++;
   }
}

I need to copy the *p to three consecutive values of dstMat, and left one zero space before and after them. That is, if my dstMat is all zero, and *p values are “1,2,3”, then my goal is to make dstMat look like” “01110 02220 03330”, etc. I hope I made this easy to understand.
My problem here is: it uses about 70 to 80 milliseconds for one frame, which is too slow for my case. I at most have 30 ms for a single frame. Is there any more efficient way for doing this?
Besides, the “dstMat” values are all zero outside the “for” loop. Do you have any ideas? Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:13:35+00:00Added an answer on June 9, 2026 at 8:13 pm

    somthing like

    for ( int row = 0; row < dstMat.rows; ++row ){
       uchar* pMed = medianMat.ptr ( row );
       uchar* pDest = dstMat.ptr ( row );  // resulting image
       pDest++; // skip the first place '0'
    
       for ( int col = 0; col < dstMat.cols; col+=5 )    {
         // copy the value from median into the destination in 3 consecutive values
         *pDest++ = *pMed; // copy 1 to dest
         *pDest++ = *pMed; // copy 1 to dest
         *pDest++ = *pMed; // copy 1 to dest
    
         pDest+=2; // skip the two zeros
         pMed++; // move to the '2'
       }
    }
    

    You can use cv::zeros to init a new cv::mat to zero

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Jw player to stream some video using the following code <script
I am using the following code to play the video using the MPMoviePlayerController ,
I have the following code in a partial view (using Spark): <span id=selectCount>0</span> video(s)
Using following code I try to get updated list of checkbuttons' corresponding text values,
Folks, I'm trying to open a youtube video in fancybox using the following code:
I am using the following code to display a video file in the android
I am using the following code to play a video inside my webpage. The
I'm using the following code to display a YouTube video. <object width=425 height=344> <param
I decode video via libavcodec, using the following code: //Open input file if(avformat_open_input(&ctx, filename,
i am using following code to show video library -(IBAction)showVideoLibrary { UIImagePickerController *videoPicker =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.